Investigate how we can warn of/prevent redefinition of built-ins
See original GitHub issueBuilding off of https://github.com/pytest-dev/pytest/pull/7428 we should investigate if there’s an elegant way we can detect and prevent redefinition of built-ins. pylint supports this under W0622, but we do not use pylint
( rationale as to why can be found here )
The high level steps of what we’d want to accomplish would then be:
- determine if we want to prevent redefinition of built ins, or stop short of blocking with some sort of warning, log message, etc. ( or if we even want to block this at all )
- determine which tool we could use to accomplish this
- perform a one time sweep to remove any overridden built ins
- hook it into our CI pipeline
Issue Analytics
- State:
- Created 3 years ago
- Comments:29 (29 by maintainers)
Top Results From Across the Web
python - Suppresing "Redefining built-in ..." pylint warning
Since pylint 1.6 there is a new option --redefining-builtins-modules . Adding builtins to its default value six.moves,future.builtins fixes ...
Read more >- VIEWS OF THE NIST NOBEL LAUREATES ON SCIENCE ...
The NIST's research programs are carried out through eight laboratories: Building ... The request for NIST will increase the ability of U.S. researchers...
Read more >Redefinition of variables | Codecademy
I'm looking at this specific exercise, but I had it happen before as well. My code looks like this: var nameString = function(name)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No worries @nicoddemus! Glad we discussed this and came to a consensus
Disclaimer: I love linters. I run pylint, flake8 + plugins, mypy and others (like vulture) myself.
From a quick look at #7449, the reason for most (or at least some) of the “noqa” comments is that we have such names exposed via our API. We definitely should not use built-in Python names as argument names, because it e.g. leads to confusing syntax highlighting in editors:
I guess the choice is less clear for methods. I suppose I’m ±0 about disabling
A003
(methods/class attributes shadowing built ins) as they are clearly namespaced and it’s something Python’s API is doing as well (e.g.logging.LogFilter.filter
). I suppose that’d eliminate the need for most noqa comments.