Git Product home page Git Product logo

flake8-variables-names's Introduction

flake8-variables-names

Build Status Maintainability Test Coverage PyPI version PyPI - Python Version

An extension for flake8 that helps to make more readable variables names.

We believe, that variable name should unmistakably shows, what it contains. Thats why we try not to use varnames with only one symbol or not to use too common names, such as result, value or info.

This extensions helps to detect such names. By default it works in non-strict mode. You can change it with --use-varnames-strict-mode parameter end extend variable names blacklist even more.

Installation

pip install flake8-variables-names

Example

Sample file:

# test.py

a = 1
foo = 2
result = a + foo

Usage:

$ flake8 test.py
test.py:1:1: VNE001 single letter variable names are not allowed
test.py:2:1: VNE002 variable name should be clarified

Error codes

Error code Description
VNE001 single letter variable names like 'XXX' are not allowed
VNE002 variable name 'XXX' should be clarified
VNE003 variable names that shadow builtins are not allowed

Contributing

We would love you to contribute to our project. It's simple:

  • Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
  • Create a pull request. Make sure all checks are green.
  • Fix review comments if any.
  • Be awesome.

Here are useful tips:

flake8-variables-names's People

Contributors

arondit avatar korneevm avatar mcproger avatar melevir avatar neutrinoceros avatar uhbif19 avatar vquadx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flake8-variables-names's Issues

One line single char variable assignement

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:

  1. Create the following code snippet:
a, b = (1, 2)
  1. Analyze the code with flake8 and the flake8-variables-names extension
  2. No VNE001 is raised

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):

  • OS: RHEL8.2
  • Python: 3.8
  • Versions:
    - flake8: 4.0.1
    - flake8-variables-names: 0.0.5

Error messages do not contain variable name

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?

Allow `use-varnames-strict-mode` with a configuration option

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.

Whether VNE003 is necessary

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!

Please remove setuptools from install_requires

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).

Update varnames blacklist

Write script, that analyze 200+ python repos, extracts varnames from the sources, output top to console and check if there are bad names.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.