PyCQA / pycodestyle

Simple Python style checker in one Python file

Home Page:https://pycodestyle.pycqa.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarify how to configure pycodestyle when using pyproject.toml

RogerMarsh opened this issue · comments

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?

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