Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove shadowing of any() #1534

Open
jlu5 opened this issue Apr 30, 2023 · 1 comment
Open

Remove shadowing of any() #1534

jlu5 opened this issue Apr 30, 2023 · 1 comment

Comments

@jlu5
Copy link
Collaborator

jlu5 commented Apr 30, 2023

For legacy reasons, Limnoria includes its own definition of any() which clashes with the Python builtins. This is pretty confusing at times because we do from supybot.commands import *

Worse, the Supybot version has completely different semantics so expected uses of the builtin just throw non-descriptive errors:

>>> supybot.commands.any([0,''])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/limnoria-2023.4.27-py3.9.egg/supybot/commands.py", line 962, in __init__
    self.__parent.__init__(spec)
  File "/usr/local/lib/python3.9/dist-packages/limnoria-2023.4.27-py3.9.egg/supybot/commands.py", line 906, in __init__
    assert isinstance(spec, context)
AssertionError

Because supybot.commands.any takes a context and the builtin takes an iterable, it should be easy to route between the two different uses. So my idea for cleaning this up would be as follows:

  1. Rename supybot.commands.any to supybot.commands.anyArguments (or whatever name is suggested)
  2. Replace supybot.commands.any with a new definition that instantiates/calls supybot.commands.any if given a context (but raises a deprecation warning), and otherwise passes on the call to the builtins version
  3. (Eventually) remove the old supybot.commands.any link
@progval
Copy link
Owner

progval commented Apr 30, 2023

Also affects:

  • format defined in supybot.utils.str and reexported by supybot.commands
  • all defined in supybot.utils.iter

Because supybot.commands.any takes a context and the builtin takes an iterable

the main use is to make the former take a single string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants