Changes to flake8 and doc string checking

dm-dev
Tags: #<Tag:0x00007fd88ce175a0>

(Tim Jenness) #1

I have recently updated the flake8 toolchain for science pipelines such that we are now running pycodestyle 2.5.0 and flake8 3.7.5. The big difference is the addition of the new --max-doc-length argument (added by @brianv0). The developer guide says that docstrings and comments should not go past column 79. Previously this was impossible to verify and much of our codebase violates this requirement. Now you can add max-doc-length = 79 to your setup.cfg file (under the max-line-length definition) and flake8 will check the code as part of its normal checks and issue a W505 warning.

As you make your code compliant please add the new check to your package. I have added this check to obs_lsst myself.


(Natelust) #2

Question, is it that docs can only go to column 79, or that docs can only be 80 columns wide? This could be really annoying (though worth dealing with still) if you are documenting something that starts 8 tabs over for instance.


(Russell Owen) #3

Thank you @brianv0 and @timj. This is much appreciated.

Does the new flake8 linter catch code comments that go beyond 79 characters? I know they are expected to follow the same rule as doc strings.

@natelust Doc strings and comments can only go to column 79. Although I agree that it can be annoying for indented code, we did have an RFC and went this route.


(Tim Jenness) #4

Yes.

PEP8 refers to columns and not width of text fields. In my editor I have one vertical ruler at column 79 and another at 110.