Comments (3)
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 DATASET
here is a variable because (as the latter says) constants are (usually) defined at the module level. Analogously, DATASET
would be a constant if defined at the class level.
Since DATASET
is a variable, it should be all lower-case. Therefore, I don't believe this is a false-positive. You've provided no evidence of your point of view, so I'm closing this.
As I said on #86, we're not here to resolve intra-team fights. If your team doesn't like this, ignore N806.
from pep8-naming.
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 in
) are stored as constants in the code object. But that's an optimisation, and would be implementation dependent.
IMHO, the visual clue that the object is not being constructed at import time is valuable.
from pep8-naming.
@lordmauve, thanks for your opinion, but let me explain.
Since it's test case, performance doesn't matter, the choice is binary: either it's constant semantically (and I write it in upper-case) or it's a variable (and should be lower-cased).
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.
Sorry again, but it have absolutely nothing to do with team fights. It's all about fundamental PEP8 understanding. Moreover, other people could and would reference this tool trying to find out how to understand PEP8's point of view on method-level constants. Like me, cause my primary goal isn't to fight any debates, my goal is to find out the truth.
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.
But there's no evidence that PEP8 has anything against it. Moreover there are a lot of examples in solid mature code written in python, using constants otherwise than on module-level. For example, django models choices.
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
from pep8-naming.
Related Issues (20)
- Broken test with flake8>=3.9.1 HOT 6
- RecursionError when checking class that inherits from same-named class
- Warning instance attributes that are not camel_case compliant
- TypedDict classes should be exempt from N815 HOT 10
- Renaming default branch to main HOT 1
- Drop dependency on flake8-polyfill HOT 2
- N815 is not being reported HOT 4
- N815 is not being reported HOT 1
- N816 does not make sense HOT 1
- False positive for N805 in a child class HOT 3
- False positive for HTTP request handler do_METHOD methods HOT 1
- False Error N805 HOT 1
- "camelcase imported as lowercase" failure in an import of a package or module HOT 12
- Add flake8_polyfill as requirement HOT 2
- Deprecation warning for options HOT 1
- Detect @classproperty mtehods as class methods HOT 3
- Feature request: ignore `N802` for methods marked with `@override` HOT 1
- Add naming rule for instance variables HOT 2
- ignore-names globbing is not case-sensitive on Windows HOT 1
- Add option to ignore N812 for specific packages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pep8-naming.