-
Notifications
You must be signed in to change notification settings - Fork 185
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
N806 Constant inside function false positive #87
Comments
In the future, please link to what you're trying to reference. The two relevant sections, as far as I'm concerned are: The former would indicate that Since As I said on #86, we're not here to resolve intra-team fights. If your team doesn't like this, ignore N806. |
One reason you shouldn't spell locals like a constant is that you still pay a cost to construct the object (dict or set in your example above) each time the function is called. In CPython, a couple of types (eg. tuples and list and set on the right hand side of IMHO, the visual clue that the object is not being constructed at import time is valuable. |
@lordmauve, thanks for your opinion, but let me explain. Although import-time construction clue is quite noteworthy. @sigmavirus24, Sorry, but I was pretty sure that including link to pep8 is redundant here, since this is a package, based on PEP8. Next, as I said in #86, "usually" doesn't mean "always" and in no way forbids another manner. So it's obvious (at least for me), the primary criterion to consider, what is constant and what is not - is semantic and purpose. E.g. if value is not supposed to be changed - it's constant. And furhter, if PEP really prohibits constants elsewhere except, the constant simply should be moved to module-level. You here not to help someone to win debates and resolve intra-team fights, I've got the idea. But I'me here just to point that misunderstanding of word "usually" in pep8 and discuss if it's not misunderstanding. And to prevent anyone from wrong speculations. And yes, I udnerstand that it's not trivial task to detect, what is constant and what is variable. Thanks for your time |
Accroding to PEP8, constants inside functions/method are not forbidden.
Following case fails test
The text was updated successfully, but these errors were encountered: