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.0.tar.gz (3.3 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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for flake8_no_chained_assignments-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c49b6760a63891cf2555c450e5fd91607edb7087dce66654a14ac55bf392351
MD5 359484a509e4797e6543e4a50f9ae3b9
BLAKE2b-256 9b2aa4c58362aa66a8cb50f66f90c899b4713a47d56f601117901b2b7d3a28c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flake8_no_chained_assignments-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48a0747fea9e6329a0948a05e392749f5a74d2bfe6c20b0dcbafc21330df9d05
MD5 eca29b7b2bb22676ee12fe5bd86c72de
BLAKE2b-256 3ccfc1e5816594492327dcc9302d8351c6e7b96aecc83a45d27022ae26df0311

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