Skip to content

STYLE don't use in-line comments for configuring flake8 #42141

Closed
@MarcoGorelli

Description

@MarcoGorelli

Check this note from the flake8 docs:

Following the recommended settings for Python’s configparser, Flake8 does not support inline comments for any of the keys. So while this is fine:

[flake8]
per-file-ignores =
# imported but unused
init.py: F401

this is not:

[flake8]
per-file-ignores =
init.py: F401 # imported but unused

However, that's exactly what we do:

pandas/setup.cfg

Lines 71 to 104 in 98e2229

[flake8]
max-line-length = 88
ignore =
E203, # space before : (needed for how black formats slicing)
W503, # line break before binary operator
W504, # line break after binary operator
E402, # module level import not at top of file
E731, # do not assign a lambda expression, use a def
S001, # found modulo formatter (incorrect picks up mod operations)
B005, # controversial
B006, # controversial
B007, # controversial
B008, # controversial
B009, # setattr is used to side-step mypy
B010, # getattr is used to side-step mypy
B011, # tests use assert False
B015, # tests use comparisons but not their returned value
B301 # false positives
exclude =
doc/sphinxext/*.py,
doc/build/*.py,
doc/temp/*.py,
.eggs/*.py,
versioneer.py,
env # exclude asv benchmark environments from linting
per-file-ignores =
# private import across modules
pandas/tests/*:PDF020
# pytest.raises without match=
pandas/tests/extension/*:PDF009
# os.remove
doc/make.py:PDF008
# import from pandas._testing
pandas/testing.py:PDF014

In each case, the comment should be moved to be on its own line, on the line before the code

Else, we risk accidentally putting something in the comments that'll mess with how flake8 works

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions