Flake8 Variables Names

0.0.6 · active · verified Tue Apr 14

Flake8 Variables Names is a Flake8 extension designed to promote more readable variable names in Python code. It identifies single-character variable names or overly common and ambiguous names such as 'result', 'value', or 'info', flagging them for clarification. The current version is 0.0.6, with releases occurring periodically to introduce new features and fix bugs.

Warnings

Install

Imports

Quickstart

After installation, `flake8-variables-names` automatically integrates with `flake8`. Run `flake8` from your terminal to apply checks. Configuration, including enabling strict mode, can be done via command-line arguments or in a `flake8` configuration file (e.g., `setup.cfg`, `tox.ini`, or `.flake8`).

# 1. Install the library
# pip install flake8 flake8-variables-names

# 2. Create a Python file, e.g., my_module.py
# def process_data(d):
#     i = 0
#     res = d * 2
#     info = 'processed'
#     return res, info

# 3. Run flake8 on your file or project
# flake8 my_module.py

# Example of flake8 output:
# my_module.py:2:13: VNE001 single letter variable names like 'd' are not allowed
# my_module.py:3:5: VNE001 single letter variable names like 'i' are not allowed
# my_module.py:4:5: VNE002 variable name 'res' should be clarified
# my_module.py:5:5: VNE002 variable name 'info' should be clarified

# 4. To enable strict mode (more aggressive checks):
# flake8 --use-varnames-strict-mode my_module.py
# Or in a config file (setup.cfg, tox.ini, or .flake8):
# [flake8]
# use-varnames-strict-mode = True

view raw JSON →