Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarcoGorelli opened this issue Jun 20, 2021 · 2 comments · Fixed by #42146
Closed

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

MarcoGorelli opened this issue Jun 20, 2021 · 2 comments · Fixed by #42146
Assignees
Labels
Code Style Code style, linting, code_checks good first issue
Milestone

Comments

@MarcoGorelli
Copy link
Member

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

@MarcoGorelli MarcoGorelli added Code Style Code style, linting, code_checks good first issue labels Jun 20, 2021
@MarcoGorelli MarcoGorelli added this to the Contributions Welcome milestone Jun 20, 2021
@RhnSharma
Copy link
Contributor

I would like to take this one.

@MarcoGorelli
Copy link
Member Author

awesome, PRs welcome

@jreback jreback modified the milestones: Contributions Welcome, 1.4 Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants