-
Notifications
You must be signed in to change notification settings - Fork 24
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
Split A002 to differentiate between arguments and class-level variables #22
Comments
We are seeing these failures as well with 1.2.1 (as well as some new appropriate failures, thank you!). +1 for this suggestion, when someone gets the time to address it. As an additional data point on the message output, ours reference the decorator as opposed to the function: class GetMap_Response(metaclass=Metaclass):
...
@property
def map(self):
"""Message field 'map'."""
return self._map
@map.setter
def map(self, value):
from nav_msgs.msg import OccupancyGrid
assert \
isinstance(value, OccupancyGrid), \
"The 'map' field must be a sub message of type 'OccupancyGrid'"
self._map = value gives the following error:
|
@clokep hi! Thanks for using and reporting issues on flake8-builtins! You are totally right, the error code is wrong, I already fixed it on master. A new release is coming soon. |
@dhood again as @clokep thanks for using and reporting issues!! Although your issue is physically close/related to @clokep issue, next time, please open a separate bug report 😉 Unfortunately, as far as my I reported it upstream on python issue tracker: see https://bugs.python.org/issue33211 What we can do meanwhile would be to create a new error message (say A003) explaining the situation, only if the function definition has a decorator. Would that be an optimal solution? I would rather not like to parse the file manually and search for the correct spot going line by line just for this corner case... I'm open to pull requests that do that though 😉 |
@clokep flake8-builtins 1.2.2 is out, let me know if it is working well for you! |
Thanks for replying so quickly! I'm now seeing A001 for those cases ("A001 "filter" is a python builtin and is being shadowed, consider renaming the variable"), which makes more sense. |
oh! I misinterpreted the initial post in this issue. I thought the issue being reported was that these failures were occurring at all (it seemed to strict to me). That's why I +1d it, and to me the error message was just a minor detail. I can see now that this ticket is just about the error message, not about the cause of the failure. Thank you for splitting it into #24 |
I just read about this issue and saw that 8b73000 changed the behavior to result in an I would argue that for the above case though (a method in a classed named after a builtin) there shouldn't be a warning in the first place. How is |
@dirk-thomas you are totally right, although I would say that even if they will be always called by Would it be ok with you to use a separate code for it? Say |
It might be "bad idea" but I would argue that the essence of the warning "thus shadows a python builtin" is not the case. Therefore I don't think there should be a warning about it (or at least the warning shouldn't be enabled by default). |
@dirk-thomas That is what I originally meant when I filed this. Note that it does shadow things since classes are their own scope: class Foobar(object):
def filter(a, b):
pass
# Anywhere in here has the built-in filter shadowed by the one above. I think that this case is much less likely to cause real issues though, it might make sense to have it off by default? |
Very good point. Some code could do the following which would be shadowing the builtin:
A new code sounds good to me then 👍 |
Ref for future readers: #28. |
E.g. with the latest version (1.2.1) I have a few examples of things like this:
This now fails with a message:
This text doesn't really make sense (
filter
isn't an argument).The text was updated successfully, but these errors were encountered: