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 monkey-patching builtins #1535

Open
jlu5 opened this issue Apr 30, 2023 · 0 comments
Open

Remove monkey-patching builtins #1535

jlu5 opened this issue Apr 30, 2023 · 0 comments

Comments

@jlu5
Copy link
Collaborator

jlu5 commented Apr 30, 2023

This sort of hack is absolutely not future proof and makes it hard to track where code originates from.

I cloned all the supported repos in PluginDownloader to see how they are used:

dynamicScope

$ grep -FRIi 'dynamic.'
Hoaas-Supybot-plugins/ImgGet/plugin.py:        ref = 'irc://%s/%s' % (dynamic.irc.server, dynamic.irc.nick)
progval-Supybot-plugins/Debian/plugin.py:        if self.registryValue('bold', dynamic.channel):

This is trivial to migrate but we can also just store a wrapped version in __builtins__ that raises a big warning when you call it via that instead of the proper import.

format

This one is used everywhere so maybe it's worth keeping. Though it's also a simple import to migrate, so having the builtin version warn about deprecation is also feasible.

$ grep -PRIi '(?<!\.)\bformat\(' | wc -l
160

force

$ grep -FRIi 'force('

No hits.

$ grep -Ii '\bforce\b' **/*.py
frumiousbandersnatch-sobrieti-plugins/plugins/XKCD/plugin.py:    def cache_add(self, rec, force=False):
frumiousbandersnatch-sobrieti-plugins/plugins/XKCD/plugin.py:        Add a rec to cache.  If force add unconditionally
frumiousbandersnatch-sobrieti-plugins/plugins/XKCD/plugin.py:        if not force and old:
fudster-supybot-plugins/DOND/plugin.py:    @wrap([getopts({'force': ''}), 'inChannel'])
fudster-supybot-plugins/DOND/plugin.py:    def stop(self, irc, msg, args, force, channel):
fudster-supybot-plugins/DOND/plugin.py:        """[--force] [<channel>]
fudster-supybot-plugins/DOND/plugin.py:        --force flag; this also works from a private message. <channel> is only
fudster-supybot-plugins/DOND/plugin.py:        if force:
fudster-supybot-plugins/DOND/plugin.py:                        '--force flag to forcibly stop the game.') %
Hoaas-Supybot-plugins/ImgGet/plugin.py:            # Force checkurl, so we can download this image aswell.
IotaSpencer-supyplugins/Sigyn/plugin.py:       force the bot to part <channel> and won't rejoin even if invited
IotaSpencer-supyplugins/Sigyn/plugin.py:       force bot to stay in <channel>
oddluck-limnoria-plugins/TextAdventures/plugin.py:            self.game[channel].terminate(force=True)
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of BTN site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of Redacted site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of Orpheus site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of MTV site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of NWCD site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of PTP site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of GGN site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of AR site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
oddluck-limnoria-plugins/Trackers/plugin.py:        Check the status of AR site, tracker, and irc. Use --message flag to force return of message, even if older than 24 hours.
progval-Supybot-plugins/Wikipedia/plugin.py:            # force serving HTTPS links

Only hits are comments, docs, helper params, or getops usage.

I think this one is safe to remove (once we update core, of course).

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

1 participant