refactor: apply suggestions from pyupgrade#2361
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2361 +/- ##
========================================
Coverage 74.1% 74.2%
========================================
Files 292 292
Lines 59476 59622 +146
========================================
+ Hits 44127 44261 +134
- Misses 15349 15361 +12
|
wpbonelli
left a comment
There was a problem hiding this comment.
UP031,UP032: related to upgrading to f-strings. Ignored since these could involve much more string and message related refactoring to adjacent code. However, a few upgraded f-strings are upgraded where it looks simple, and in user-facing docs.
UP015: for redundant file modes. Kept default file modes (e.g. open(..., "r") to keep it more clear, e.g. when a file pointer object is left open for reading (and then closed many lines further down, as is often done with legacy flopy code)
We should keep these in mind going forward.. Probably not worth any extra attention in the legacy flopy.mf6 since that will get a rewrite anyway, but elsewhere legacy code could be gradually updated as we find time
This PR refactors the codebase with Ruff's pyupgrade check, based on pyupgrade. Not all suggestions are applied, and some manual edits were applied in addition to the affected code. Removing
target-versionfrom the ruff options allows this to be automatically evaluated from pyproject.toml.The rules that were applied include:
Meanwhile, these rules were somewhat ignored:
UP015: for redundant file modes. Kept default file modes (e.g.open(..., "r")to keep it more clear, e.g. when a file pointer object is left open for reading (and then closed many lines further down, as is often done with legacy flopy code)