Skip to main content

Flake8 plugin to prohibit chained assignments (e.g., a = b = c)

Project description

flake8-no-chained-assignments

Tests PyPI version Python versions License

A flake8 plugin that prohibits chained assignments.

Chained assignments (a = b = value) can obscure intent and lead to subtle bugs when mutable objects are involved. This plugin makes them a lint error, encouraging explicit, readable assignments instead.

Error codes

Code Description
NCA001 Chained assignments are prohibited

Example

# Bad — triggers NCA001
a = b = 0
x = y = z = []

# Good
a = 0
b = 0

Installation

pip install flake8-no-chained-assignments

Or add it to your project's dev dependencies:

pip install -e ".[dev]"

Usage

Once installed, flake8 picks up the plugin automatically:

flake8 your_code.py

Example output:

your_code.py:3:1: NCA001 Chained assignments are prohibited

Configuration

You can ignore the rule per-line with the standard flake8 mechanism:

a = b = 0  # noqa: NCA001

Or disable it project-wide in setup.cfg / .flake8:

[flake8]
extend-ignore = NCA001

Development

git clone https://github.com/mrsndmn/flake8-no-model-forward-call
cd flake8-no-model-forward-call
pip install -e ".[dev]"
pytest tests/ -v

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_no_chained_assignments-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_no_chained_assignments-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file flake8_no_chained_assignments-0.1.1.tar.gz.

File metadata

File hashes

Hashes for flake8_no_chained_assignments-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e68e94039c0ff5bc901a9b085395addc52833b1f1d84ae319d2a4fc865d92deb
MD5 a0d8b1f898388cc717baada408bfed11
BLAKE2b-256 2191268536140a92c89a33c221b09e9b9a08cfbd5705e1f0dc5348094a9e22d1

See more details on using hashes here.

File details

Details for the file flake8_no_chained_assignments-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_no_chained_assignments-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a3c01af5e2e61e3ae253318f0ee1834eb3e5c3d7fa5be8d8f871a67aa6ec05
MD5 ea9c98518762acc5e027bbb276d2527d
BLAKE2b-256 a6712fd27d8f3c9e62404c3408ad901dac32d7b825e263c77d7dd5f235c2e57e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page