Skip to content

Commit

Permalink
Deprecate using supybot.dynamicScope without an import (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlu5 committed Jul 1, 2023
1 parent b374418 commit eb74166
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/Aka/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.httpserver as httpserver
from supybot.dynamicScope import dynamic
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('Aka')

Expand Down
1 change: 1 addition & 0 deletions plugins/Factoids/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.httpserver as httpserver
from supybot.dynamicScope import dynamic
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Factoids')

Expand Down
1 change: 1 addition & 0 deletions plugins/Google/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.dynamicScope import dynamic
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Google')

Expand Down
1 change: 1 addition & 0 deletions plugins/Relay/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.utils.structures import MultiSet, TimeoutQueue
from supybot.dynamicScope import dynamic
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Relay')

Expand Down
1 change: 1 addition & 0 deletions plugins/Success/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
from supybot.dynamicScope import dynamic
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Success')

Expand Down
1 change: 1 addition & 0 deletions src/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import inspect
import warnings

from .dynamicScope import dynamic
from . import (conf, ircdb, irclib, ircmsgs, ircutils, log, registry,
utils, world)
from .utils import minisix
Expand Down
1 change: 1 addition & 0 deletions src/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, \
utils, world
from .dynamicScope import dynamic
from .utils import minisix
from .i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization()
Expand Down
1 change: 1 addition & 0 deletions src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .utils import minisix
from .utils.net import isSocketAddress
from .version import version
from .dynamicScope import dynamic
from .i18n import PluginInternationalization
_ = PluginInternationalization()
if minisix.PY2:
Expand Down
13 changes: 12 additions & 1 deletion src/dynamicScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
###

import sys
import warnings

class DynamicScope(object):
def _getLocals(self, name):
Expand All @@ -48,6 +49,16 @@ def __getattr__(self, name):
def __setattr__(self, name, value):
self._getLocals(name)[name] = value

(__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)['dynamic'] = DynamicScope()
class _DynamicScopeBuiltinsWrapper(DynamicScope):
def __getattr__(self, name):
warnings.warn('Using DynamicScope without an explicit import is '
'deprecated and will be removed in a future Limnoria '
'version. Use instead: '
'from supybot.dynamicScope import dynamic',
stacklevel=2)
return super().__getattr__(name)

dynamic = DynamicScope()
__builtins__['dynamic'] = _DynamicScopeBuiltinsWrapper()

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
1 change: 1 addition & 0 deletions test/test_dynamicScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
###

from supybot.test import *
from supybot.dynamicScope import dynamic

class TestDynamic(SupyTestCase):
def test(self):
Expand Down

0 comments on commit eb74166

Please sign in to comment.