Skip to content

Remove monkey-patching builtins #1535

Open
@jlu5

Description

@jlu5

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).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions