PyCQA / pycodestyle

Simple Python style checker in one Python file
https://pycodestyle.pycqa.org
Other
5.02k stars 756 forks source link

Clarify how to configure pycodestyle when using pyproject.toml #1193

Closed RogerMarsh closed 1 year ago

RogerMarsh commented 1 year ago

While converting project configurations from setup.cfg to pyproject.toml a [pycodestyle] section was encountered.

After seeing issues 1180 and 813 I thought pycodestyle might have to be dropped from the code evaluation repertoire until I remembered that an 'sdist' stage in 'python -m build ...' wrote a setup.cfg file.

(read hash, the 'this line is a comment marker', for '!'. I did not know 'hash' meant 'line of bold text' in this editor.)

So I cut down the setup.cfg file to

! pycodestyle does not support toml in the sense that a [tool.pycodestyle] ! section in a pyproject.toml file is ignored. ! However 'python -m build ...' an sdist writes a setup.cfg file, or if one ! already exists rewrites it ignoring comments and appends some stuff. ! Hence the non-comment content of this setup.cfg survives to provide the ! [pycodestyle] section.

[pycodestyle] ! E203 to fit black formatting and pylint. ! W503 is only default ignore which occurs at 2023-07-14, and style is what ! black formatting does if needed. My preference is break after operator ! but easier to let black do what it wants. ! E722 is given for 'bare except' even if re-raised but pylint reports ! 'bare-except' only when the exception is not re-raised. ! E402 not added to 'ignore' list because it was possible to get rid of ! the reports without a corresponding 'wrong-import-position' from pylint ! by moving all unconditional imports (two at 2023-07-18) to before the ! conditional imports. ignore=E203,W503,E722

and got a clean pycodestyle report from the before, and the after, conversion projects; and was able to get the pycodestyle reports by suppressing the ignore.

I did not look at pycodestyle documentation to see if something like this was mentioned because I assumed the answers to 1180 and 813 would have said 'read the documentation' if such was said.

Should the documentation make this clear?

asottile commented 1 year ago

it is not supported. there are many config files that are not supported so it does not make sense to enumerate them