ing-bank / popmon

Monitor the stability of a Pandas or Spark dataframe ⚙︎
https://popmon.readthedocs.io/
MIT License
493 stars 33 forks source link

Apply Ruff to popmon #259

Closed sbrugman closed 1 year ago

sbrugman commented 1 year ago

Run ruff and resolve any issues found

The popmon ruff configuration works with nbqa for notebooks, and has selected rules for tests, sphinx config and examples.

Some checks are disabled, but would benefit from manual refactoring.

There is also a set of rules that can be mechanically refactored, for violations that occur more often. Here autofix would be a great improvement over manual refactor:

 # Prefer autofix
"PD011", # [1] .to_numpy() instead of values
"PD003", # [1]`.isna` is preferred to `.isnull`; functionality is equivalent
"PT018", # [2] Assertion should be broken down into multiple parts
"RET504", # [3] Unnecessary variable assignment before `return` statement
"RET506", # Unnecessary `else` after `raise` statement
"PTH123", # [4] `open("foo")` should be replaced by `Path("foo").open()`
"PTH120", # [4] similar to above
"RET505", # Unnecessary `else` after `return` statement
"SIM102", # (when comments are in the statement) Use a single `if` statement instead of nested `if` statements
"SIM114", # (when comments are in the statement) Combine `if` branches using logical `or` operator
"G004", # Logging statement uses f-string

A couple of them are already in progress. Related autofix PRs:

\cc @charliermarsh in case you are interested. Thanks a lot for all your work on ruff :) I'm considering adding the remaining autofixes too if that is appreciated.

charliermarsh commented 1 year ago

(Thank you @sbrugman for all your contributions!)