flake8-hangover
Flake8 plugin to prevent specific hanging indentations (and more).
Installation
pip install flake8-hangover
Errors
| Code | Description |
|---|---|
| FHG001 | Function argument has hanging indentation |
| FHG002 | Function call positional argument has hanging indentation |
| FHG003 | Function call keyword argument has hanging indentation |
| FHG004 | First function argument must be on new line |
| FHG005 | Close bracket have different indentation with open bracket |
Examples
FHG001 Function argument has hanging indentation
# ERROR: Hanging indentation on `extra_param`
def _hello_world(param: pd.DataFrame, other_param: sklearn.base.BaseEstimator,
extra_param: Optional[Dict] = None) -> str:
...
# ERROR: Not hanging indentation, but params are "over indendented" by 2 tabs
# instead of just 1 tab
def _calc_pdp(
df: pd.DataFrame,
estimator: sklearn.base.BaseEstimator,
feature_columns: List[str], pdp_kwarg: Optional[Dict] = None,
) -> List[pdp.PDPIsolate]:
pdp_isolates = []
# OK: Correct indentation
# BUT! It will cause FHG004 error (it's more strict) for `param` argument
def _hello_world(param: pd.DataFrame, other_param: sklearn.base.BaseEstimator,
extra_param: Optional[Dict] = None) -> str:
...
# OK: Best practice
def _hello_world(
param: pd.DataFrame,
other_param: sklearn.base.BaseEstimator,
extra_param: Optional[Dict] = None,
) -> str:
...
FHG002 Function call positional argument has hanging indentation
# ERROR: Hanging indentation on `other_param`
if a != b:
error_message = get_error_message(param,
other_param)
# OK: Correct indentation
if a != b:
error_message = get_error_message(param,
other_param,
)
# OK: Best practice
if a != b:
error_message = get_error_message(
param,
other_param,
)
FHG003
# ERROR: Keyword argument `other_value` has hanging indentation
def foo():
result = my_func(value='name',
other_value='hello')
# Correct indentation, but looks terrible
# TODO: Rule like FHG004 for function calls is not yet implemented
def foo():
result = my_func(value='name',
other_value='hello')
# OK: Best practice
def foo():
result = my_func(
value='name',
other_value='hello',
)
FHG004 First function argument must be on new line
This is more strict rule that requires any function definition with multiline arguments to place first argument on new line.
# ERROR: Positional argument `foo` must be on new line
def test_something(foo, bar,
buzz):
...
# ERROR: Same thing but for keyword argument `foo`
def test_something(foo='Hello',
value='World',
):
return key + value
# OK: Argument `foo` is on new line
def test_something(
foo, bar, buzz,
):
...
# OK: Best practice (but sometimes it's not good looking for over 5 params, for example)
def test_something(
foo,
bar,
buzz,
):
...
FHG005 Close bracket have different indentation with open bracket
# ERROR: Close bracket on line with last parameter not allowed
func(
123,
456)
# OK: Close bracket on new line
func(
123,
456,
)
Same thing with assigments:
# ERROR: Close bracket not aligned with open bracket's line
result = [
1,
2]
# OK: Close bracket aligned with first line
result = [
1,
2,
]
Metadata
Release files for flake8-hangover 0.0.5
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-hangover-0.0.5.tar.gz | 10.5 kB | Without provenance | Details for flake8-hangover-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flake8_hangover-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for flake8_hangover-0.0.5-py3-none-any.whl |
Total release size: 18.2 kB
Release files / flake8-hangover-0.0.5.tar.gz
| Download URL | flake8-hangover-0.0.5.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2bd04ad3cb09cc85c3ad19add8356482d65eec6c4fbedb33a2e6b5e9e7bac2d
|
|
BLAKE2b-256 checksum How to use checksums |
47a8856c69fd8742d072e864dbb3fd27b00e15e2e40e515c64a7e9e3c4e89750
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / flake8_hangover-0.0.5-py3-none-any.whl
| Download URL | flake8_hangover-0.0.5-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c90a2074c11b00ddb9b980fbc0182f2c85b363ff9f9daf527e2f470c3ece8fc4
|
|
BLAKE2b-256 checksum How to use checksums |
10609cdeb8d825f5dbeb37a3b0c992ef26d8deb134d70950ac5b1ae8615e69b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Security for flake8-hangover 0.0.5
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.