-
Notifications
You must be signed in to change notification settings - Fork 5
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
Enable all pycodestyle and isort rules in Ruff and fix violations #1463
base: master
Are you sure you want to change the base?
Conversation
db883e1
to
e1b1ef8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tdm32 Have you got any active branches that update src/tlo/methods/hiv.py
that the below changes (reformatting lines to make them conform with 120 character line length limit) might conflict with? If so we can hold off merging this until those changes are in to master
and then update here.
Updates Ruff configuration to enable all pycodestyle error (
E
prefix), pycodestyle warning (W
prefix) and isort (I
prefix) rules. Previously we used the default Ruff configuration which only selects a subset of the E rules (E4, E7 and E9), no W rules and doesn't enable any isort rules (but we separately used isort package to check import ordering).The only violations of the additional pycodestyle error rules now enabled were of the E501
lines-too-long
rule, and this PR also fixes all instances of this rule being violated insrc/tlo
andtests
, and adds a global directory level ignore forsrc/scripts
(under the assumption we probably don't care too much about formatting violations in the scripts).The only violations of the additional pycodestyle warning rules enabled were of W291
trailing-whitespace
and W293blank-line-with-whitespace
rules, with the this PR also fixing all instances of this rule being violated.Ruff's isort rules are very close to the rules checked by isort itself and the only violation after enabling isort rules was due to presence of a commented out import in src/scripts/hiv/projections_jan2023/analysis_full_model.py. The main advantages of using Ruff rules rather than separate isort are a slight improvement to run time of checks by not requiring separate installation and running of isort, and more usefully, for those who use a Ruff integration in their IDE, unsorted imports will now be flagged directly in IDE. I am still commonly caught out by the isort check failing on pushing regularly, so this should hopefully make this less likely by making it easier to catch violations earlier!
While this PR touches a lot of files, all of the changes should have no effect on actual code as they are just changes to whitespace / line reflowing (hiding whitespace changes in diff should make it a bit easier to review!).