Closed jasonlyik closed 7 months ago
@jasonlyik Black, pylint, flake8 are helpful for this. Pre-commit needs to be used to actually enforce, however, and the entire project would need to be formatted and linted at the start. Though there are ways you could do automatic code formatting via a workflow, I really would not recommend that approach as no tool is perfect and there will be times when a tool does something undesirable. For example, black does not handle string literals well at all when it addresses maximum line length. Specifically, it likes to add additional quotation marks so that the line is longer than ever without splitting the content up across multiple lines. Black also won't format your docstrings or comments, and I'm not aware of a tool that does.
Pre-commit with black, pylint, and flake8, would be my rec - here's an example of a repo using pre-commit with the second two (I removed black because of the above issue, but would try using it first).
I can help set this up if you like.
@cerrussell Thanks! It would be great if you could help to set this up. We haven't had an enforced style throughout our codebase, which tools would be useful to update the whole thing to a consistent style? Also do you have any sense of how difficult that would be?
@jasonlyik It would not be difficult - there are two separate PRs I would propose. The second step of PR 2 would be optional, but I would recommend not skipping as they are such simple fixes. Otherwise those items will need to be added to the exclusions in step 3.
PR 1
PR 2
Should add some code formatter and linter to make the whole repo more consistent