-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add allow-redefined-builtins option to variable checker #3643
Add allow-redefined-builtins option to variable checker #3643
Conversation
Very simple approach and only for local names. Not sure if module-level variables should be supported as well, though it makes sense just for consistency. Guidance is appreciated. |
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, the code is clean, and it has proper tests. This is mergeable. Why would you want to allow some redefined builtins though ?
@Pierre-Sassoulas the reason is explained in linked issue and commit message, I can add more details as I see them. Thanks for inspecting the code. I'd also like to hear your opinion about including module level variables in ignore list. There are two more places in |
5c581e5
to
24acb35
Compare
@Pierre-Sassoulas have you enough time to answer this? |
Sorry I missed your answer completely @kapsh. This make sense. Regarding your question, I'm not familiar with that part of the code, but looking at it from a functional perspective, I think a global named |
I would really love this feature. Is there a chance this might get merged soon? |
I re-read the discussion, it seems to me that a global variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether or not we allow this functionality depends on how we view pylint as a whole. In the past pylint has been very rigid in what it will and won't accept. I've had feedback that this makes pylint seem "too opinionated" and some people don't like pylint as a result. So I have wanted pylint to move towards allowing things to be more configurable so that it encourages you to do the right thing by default but also give users the option to configure things more to their liking if they know what they are doing.
I think this pull request is a good step in that direction so I'm happy with it!
That is great to hear! Thank you for reacting so fast! |
@AWhetter I am relieved to hear that this feature is desirable. Let me just update it and resolve conflicts here. @Pierre-Sassoulas agreed, shadowing in globals is easy to miss and shouldn't be permitted by this option. Tests will make it clearer. |
1732666
to
91ed3fe
Compare
@kapsh thanks for this PR. I think it is definitely a good idea. |
@Pierre-Sassoulas do you approve? |
91ed3fe
to
dbee15b
Compare
Rebased again because of conflicts in changelog. |
Some builtins have little-to-no use in application code while being convenient as variables names (e.g. id, dir). New option allows to configure allowed to override names for redefined-builtin checker. Closes pylint-dev#3263
dbee15b
to
942b02f
Compare
Thank you for the merge request, definitely something that will make pylint less annoying to use ! |
Steps
doc/whatsnew/<current release.rst>
.Description
Some builtins have little-to-no use in application code while being
convenient as variables names (e.g. id, dir). New option allows
to configure allowed to override names for redefined-builtin checker.
Type of Changes
Related Issue
Closes #3263