best-doctor / flake8-variables-names Goto Github PK
View Code? Open in Web Editor NEWA flake8 extension that helps to make more readable variables names
License: MIT License
A flake8 extension that helps to make more readable variables names
License: MIT License
Write script, that analyze 200+ python repos, extracts varnames from the sources, output top to console and check if there are bad names.
Please remove setuptools
from install_requires
in setup.py
. When using tools that compile list of deployable packages setuptools will be inadvertantly included and when using well known tools like pip-tools
to compile a requirements file with hashes it will inadvertantly issue a warning that including setuptools
in the compiled requirements file is considered unsafe (chicken egg issue).
Try to guess boolean variable and check if it starts with scecified prefixes (eg. is_
/has_
).
VNE002
error message looks like this:
./some/dirs/some_file.py:30:9: VNE002 variable name should be clarified
It would be easier to understand and group errors, if the error message included variable name, like this:
./some/dirs/some_file.py:30:9: VNE002 variable name 'some_var' should be clarified
This style is used by flake8:
./some/dirs/some_file.py:18:5: F841 local variable 'some_var' is assigned to but never used
Is static error message an intentional design decision?
Describe the bug
When assigning several single char variables on a single line (from a tuple for example), the VNE001 error is NOT raised.
To Reproduce
Steps to reproduce the behavior:
a, b = (1, 2)
Expected behavior
I would expect VNE001 is raised twice for the a
and b
variables, like it is done for the following code:
a = 1
b = 2
# VNE001 single letter variable names like 'a' are not allowed
# VNE001 single letter variable names like 'b' are not allowed
Desktop (please complete the following information):
Is your feature request related to a problem? Please describe.
When multiple execution contexts are defined (e.g. dev-env, pre-commit, CI), it will be nice to have a SSOT (https://en.wikipedia.org/wiki/Single_source_of_truth) of whether this option is enabled or not.
Describe the solution you'd like
"For all of flake8's configuration streams" (e.g. .flake8
, pyproject.toml
), I can set use-varnames-strict-mode = true
on the file, and flake8-variables-names
picks it up.
Describe alternatives you've considered
pre-commit has args
to pass custom args to tools, but I cannot affect how the dev-env reacts to that.
e.g. developers IDE may not by-default activate that setting, and, even if the developer remembers to run manually on the terminal flake8 --use-varnames-strict-mode
, s/he will still get no feedback while writing code.
Additional context
Add any other context or screenshots about the feature request here.
I assume this was a copy-paste?
Now blacklists are builtin, they should be configured.
First of all, thank you for a great plugin!
I've also been using flake8-builtins in my regular plugin set for quite some time, it solves one specific problem for it.
But I noticed that your plugin also detects builtins and needs to add a separate code so that flake8 does not complain.
For example:
id = Column(Integer, primary_key=True) # noqa: A003, VNE003
Sure, I could just add VNE003 to ignore list, but maybe there's a way to make the plugin more specialized?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.