Skip to content
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

Align style checks with jwst #383

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

braingram
Copy link
Collaborator

@braingram braingram commented Jan 29, 2025

spacetelescope/jwst#9081 introduced major changes to the code style checks in jwst.

Since this package primarily serves jwst this PR updates the style checks here to more closely match those in jwst.

Regtests: https://github.com/spacetelescope/RegressionTests/actions/runs/13039378253
show 1 error test_exec_time_0_crs which I'm chalking up to a slower-than-usual runner which took 11 instead of 10 seconds. I expect these may need to be re-run after review so I'll open this PR for review now.

Branch protections will need to be updated after this PR is merged to check for pre-commit success.

Tasks

  • update or add relevant tests
  • update relevant docstrings and / or docs/ page
  • Does this PR change any API used downstream? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • run jwst regression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>")
news fragment change types...
  • changes/<PR#>.feature.rst: new feature
  • changes/<PR#>.bugfix.rst: fixes an issue
  • changes/<PR#>.doc.rst: documentation change
  • changes/<PR#>.removal.rst: deprecation or removal of public API
  • changes/<PR#>.misc.rst: infrastructure or miscellaneous change

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 73.12253% with 204 lines in your changes missing coverage. Please review.

Project coverage is 78.17%. Comparing base (788f7bd) to head (1ce97af).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/stdatamodels/jwst/transforms/models.py 31.70% 84 Missing ⚠️
src/stdatamodels/jwst/datamodels/wcs_ref_models.py 27.08% 35 Missing ⚠️
...tamodels/jwst/transforms/converters/jwst_models.py 67.27% 18 Missing ⚠️
src/stdatamodels/fits_support.py 87.35% 11 Missing ⚠️
src/stdatamodels/model_base.py 87.67% 9 Missing ⚠️
src/stdatamodels/schema.py 85.41% 7 Missing ⚠️
src/stdatamodels/validate.py 50.00% 7 Missing ⚠️
src/stdatamodels/jwst/datamodels/asn.py 37.50% 5 Missing ⚠️
src/stdatamodels/jwst/datamodels/util.py 77.27% 5 Missing ⚠️
src/stdatamodels/properties.py 89.79% 5 Missing ⚠️
... and 9 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #383       +/-   ##
===========================================
+ Coverage   67.59%   78.17%   +10.57%     
===========================================
  Files         115      115               
  Lines        5932     5145      -787     
===========================================
+ Hits         4010     4022       +12     
+ Misses       1922     1123      -799     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

"UP015", # unnecessary open(file, "r"). no harm being explicit
"TRY003", # prevents custom exception messages not defined in exception itself.
"ISC001", # single line implicit string concatenation. formatter recommends ignoring this.
"PTH123", # use Path.open instead of open
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are lots of open uses in the code. I don't see why Path(filename).open is preferred.

"TRY003", # prevents custom exception messages not defined in exception itself.
"ISC001", # single line implicit string concatenation. formatter recommends ignoring this.
"PTH123", # use Path.open instead of open
"UP038", # isinstance with | instead of ,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I'm aware isinstance(foo, FooType | BarType) and isinstance(foo, (FooType, BarType)) are equivalent and the latter is faster.

"B904", # raise ... from ?, when and where do we want to not use the default chain?
"NPY002", # numpy rng, will require finding the right replacements
"S101", # asserts are used in many non-test places
"SLF001", # private member access, this is overly restrictive
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this in the "fix later" category but I'm not convinced it's worth the effort for the number of what I would consider "false positives".

- id: ruff
args: ["--fix"]
- id: ruff-format
# - repo: https://github.com/numpy/numpydoc
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even after excluding test.* items this shows 2884 failures. My vote is to enable and attempt to address these in a follow up PR.

@braingram braingram marked this pull request as ready for review January 30, 2025 19:04
@braingram braingram requested a review from a team as a code owner January 30, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant