-
Notifications
You must be signed in to change notification settings - Fork 10
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 deprected builtins in MODULE_BUILTINS #89
Comments
I originally intended to add testing for this in #85; however, it's more challenging than I original though. How do we determine if a builtin is deprecated or platform dependent? I couldn't find a simple way to determine this dynamically (i.e. at runtime). What's even more complicated is that not all builtins are present in the
This is a no go. The platform you run ssort on should be completely independent of the platforms you can run your application on. For instance, a developer may personally develop on Linux, and therefore run ssort on Linux, but have their application target both Linux and Windows. This is a perfectly valid use case which we must anticipate.
As mentioned above, this would be difficult, if not impossible because of platform dependent builtins. |
What would be the downside to simply removing the list of builtins and ignoring unresolved dependencies? My feeling is that it was something that I introduced when I was trying to get On the plus side, unresolved dependency errors are endlessly infuriating during development as they block other auto-formatters from running. |
Using a function like this ( def test_no_additional_builtins():
additional = MODULE_BUILTINS
additional -= _get_builtins()
additional -= _get_init_builtins()
additional -= _get_main_builtins()
additional -= _get_module_builtins()
assert not additional we can determine a list of builtins that are defined in This is a complete list of additional elements. Note that all dunder methods are indeed builtins: {
'StandardError',
'WindowsError',
'_',
'apply',
'basestring',
'buffer',
'cmp',
'coerce',
'execfile',
'file',
'intern',
'long',
'raw_input',
'reduce',
'reload',
'unichr',
'unicode',
'xrange'
} Basically all of these are relics of Python 2 and no longer in use:
Thus, only
|
Python 2 builtins also important for the same reason as platform specific ones: code can run under different versions of python as well as on different platforms. If we have a list of builtins then it should list all possible builtins. |
Is it ever safe to dereference |
I still have an deep seated aversion to deleting stuff I've spent a lot of time on so this hurts, but I think this is the better solution: #96 |
I think the question then is: do we want to support legacy python 2 code snippets? There is at least on test in I personally would argue that we are in 2023 and python 2 should not be used so remove those and call it a day. |
Based on discussion with you and @jgberry, have determined that removing the warnings in #96 is not sufficient to allow removing the builtins list safely. Going to leave this open for a couple more years. |
_builtins.py
defines MODEULE_BUILTINS.The following elements are not found in
import builtins; dir(builtins)
:My question is: Do we need these elements?
For example:
StandardError
originates from Python 2 and has long been deprecated (https://portingguide.readthedocs.io/en/latest/exceptions.html)WindowsError
is OS specific and should only be included if the OS is windows.exit
andquit
.So my question is, do we need these elements?
Can we determine MODULE_BUILTINS dynamically?
The text was updated successfully, but these errors were encountered: