flake8-multiline-conditionals-comprehensions
flake8 plugin that works on conditional expressions and comprehension expressions to enforce each segment to be put on a new line.
Contents
Options
The flag --select_mcc2 can be used to select the set of errors
to include. By default, the active errors are MCC200, MCC201, MCC202,
MCC220, MCC221, MCC223.
Comprehension Errors
MCC200
A comprehension expression should place each of its generators on a separate line.
# Bad
[x+y for x in range(10) for y in range(10)]
# Good
[
x + y
for x in range(10)
for y in range(10)
]
MCC201
A multiline comprehension expression should place each of its segments (map, generator, filter) on a separate line.
# Bad
[x+y for x in range(10)
for y in range(10) if x+y > 5]
# Good
[
x + y
for x in range(10)
for y in range(10)
if x + y > 5
]
MCC202
A comprehension expression should not contain multiple filters.
# Bad
[x for x in range(10) if x % 2 == 0 if x % 3 == 0]
# Good
[x for x in range(10) if x % 2 == x % 3 == 0]
MCC203
A comprehension expression should not span over multiple lines.
# Bad
[x + y
for x in range(10) ]
# Good
[x+y for x in range(10)]
MCC204
A comprehension expression should span over multiple lines.
# Bad
[x for x in range(10)]
# Good
[x
for x in range(10)]
Condition Errors
MCC220
A multiline conditional expression should place each of its segments on a separate line.
# Bad
1
if something() else 0
# Good
1
if something()
else 0
MCC221
A conditional expression used for assignment should be surrounded by parantheses.
# Bad
a = 1 if something() else 0
# Good
a = (1 if something() else 0)
MCC222
A conditional expression should not contain further conditional expressions.
# Bad
1 if x > 0 else -1 if x < 0 else 0
# Good
if x > 0:
return 1
elif x < 0:
return -1
else:
return 0
MCC223
A conditional expression should not span over multiple lines.
# Bad
1
if something()
else 0
# Good
1 if something() else 0
MCC224
A conditional expression should span over multiple lines.
# Bad
1 if something() else 0
# Good
1
if something()
else 0
MCC225
Conditional expressions should not be used.
Metadata
Release files for flake8-multiline-conditionals-comprehensions 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flake8-multiline-conditionals-comprehensions-2.0.tar.gz | 5.1 kB | Without provenance | Details for flake8-multiline-conditionals-comprehensions-2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flake8_multiline_conditionals_comprehensions-2.0-py3-none-any.whl | Python 3 | none | any | Details for flake8_multiline_conditionals_comprehensions-2.0-py3-none-any.whl |
Total release size: 11.3 kB
Release files / flake8-multiline-conditionals-comprehensions-2.0.tar.gz
| Download URL | flake8-multiline-conditionals-comprehensions-2.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cb7274984c0696ce3d8d914f92b0852a2705817142454c3141c8cb66c62119f
|
|
BLAKE2b-256 checksum How to use checksums |
443c782f8e5a96daccb8405ed1013f4d11c2335eda226160e78f1ded7898b69d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / flake8_multiline_conditionals_comprehensions-2.0-py3-none-any.whl
| Download URL | flake8_multiline_conditionals_comprehensions-2.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b43fb271d3fbefc40cb44fe80568e4cac6320bb3ea4aceed17c913cd72d19ff7
|
|
BLAKE2b-256 checksum How to use checksums |
cdd88be2af86ab41da877b8caef2ea79958fac68dea4f85b19eba26fd7b3eaf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for flake8-multiline-conditionals-comprehensions 2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.