flake8-fill-one-line
A Flake8 plugin to ensure an expression can be written in one line without exceeding the maximum length (160 characters by default) limit.
Installation
Install from pip with:
pip install flake8-fill-one-line
Reported errors
Code |
Rule |
|---|---|
FOL001 |
import statement can be written in one line |
FOL002 |
function call can be written in one line |
FOL003 |
assignment can be written in one line |
FOL004 |
return statement can be written in one line |
FOL005 |
function definition can be written in one line |
FOL006 |
with statement can be written in one line |
FOL007 |
if statement can be written in one line |
Used options
max_line_length - option from Flake8, length limit for line
skip-std-names - ignore tuple(), list(), set(), dict() calls (used by default)
skip-multiline-arguments - ignore function calls with arguments on multiple lines (used by default)
Examples
Imports:
# wrong:
import sys, \
argparse
from random import randint as rand_int, \
sample, choice as \
random_choice
# right:
import sys, argparse
from random import randint as rand_int, sample, choice as random_choice
Calls and assignments
# wrong:
f(1, 2, 3,
4, 5, 6, 7,
8, 9)
# right:
f(1, 2, 3, 4, 5, 6, 7, 8, 9)
# wrong:
some_var = foo(1,
a=3,
b=42)
# right:
some_var = foo(1, a=3, b=42)
# wrong:
def f(a: int, b: int) -> int:
return f1(a,
b,
a + b)
# right:
def f(a: int, b: int) -> int:
return f1(a, b, a + b)
# wrong:
def foo(a: int, b: int):
return a - b * 3 if \
b < 4 \
else foo(a - 1, b + 1)
# right:
def foo(a: int, b: int):
return a - b * 3 if b < 4 else foo(a - 1, b + 1)
Function definitions
# wrong
def f(a,
b,
c):
return a + b * c
# right:
def f(a, b, c):
return a + b * c
# wrong
def f2(
a: str,
b: tuple, *some_args,
**kwargs_name
) -> str:
pass
# right:
def f2(a: str, b: tuple, *some_args, **kwargs_name) -> str:
pass
With statements
# wrong:
with open("some_file.txt") as \
f:
f.read()
# right:
with open("some_file.txt") as f:
f.read()
# wrong:
with open("f1.txt") as f1, \
open("f2.txt", "w") as f2:
f2.write(f1.read())
# right:
with open("f1.txt") as f1, open("f2.txt", "w") as f2:
f2.write(f1.read())
If statements
# wrong:
if (
a < b and
c < d and
a + b == c - d
):
pass
# right:
if a < b and c < d and a + b == c - d:
pass
# wrong:
if a < \
b:
pass
# right:
if a < b:
pass
# wrong:
for i in range(100):
if (i < 5 or
i > 10):
pass
elif i == 2 or \
i == 3 or i == 11 \
or i == 28:
pass
elif 47 <= i <= 58:
pass
elif i * (20 -
i) < 0:
pass
# right:
for i in range(100):
if i < 5 or i > 10:
pass
elif i == 2 or i == 3 or i == 11 or i == 28:
pass
elif 47 <= i <= 58:
pass
elif i * (20 - i) < 0:
pass
Metadata
Release files for flake8-fill-one-line 0.4.2
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_fill_one_line-0.4.2.tar.gz | 7.3 kB | Without provenance | Details for flake8_fill_one_line-0.4.2.tar.gz |
Release files / flake8_fill_one_line-0.4.2.tar.gz
| Download URL | flake8_fill_one_line-0.4.2.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
581be00faac1c6e55e3e8a946476f93357a3e8397eac59b18451434fd5d7de62
|
|
BLAKE2b-256 checksum How to use checksums |
21016f6a927d4d2f772935370a7fc3ce0a576534fe9fe0227e2ef1ee2d58d454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for flake8-fill-one-line 0.4.2
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.