-
Notifications
You must be signed in to change notification settings - Fork 26
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
Turn on documentation rules in pre-commit #406
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #406 +/- ##
==========================================
+ Coverage 78.16% 78.44% +0.27%
==========================================
Files 115 109 -6
Lines 5144 5084 -60
==========================================
- Hits 4021 3988 -33
+ Misses 1123 1096 -27 ☔ View full report in Codecov by Sentry. |
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.
@nden Would you please take a look at all the TODOs in this file? Or if you're unfamiliar with these, maybe you know who is familiar?
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.
Thanks for putting this together. I haven't finished reviewing the changes but figured I'd submit the comments so far.
I did not yet review:
- jwst.datamodels.wcs_ref_models.py
- jwst.transforms.models
src/stdatamodels/fits_support.py
Outdated
Returns `True` if the given `key` is a built-in FITS keyword, i.e. | ||
a keyword that is managed by ``astropy.io.fits`` and we wouldn't | ||
want to propagate through the `_extra_fits` mechanism. | ||
Check if key is a fits builtin. |
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.
Check if key is a fits builtin. | |
Check if key is a FITS builtin. |
pyproject.toml
Outdated
@@ -119,6 +119,27 @@ select = [ | |||
"E722", | |||
] | |||
|
|||
[tool.numpydoc_validation] | |||
checks = [ | |||
"all", |
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.
Since all is here do we need the other rules?
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.
This syntax gives us "all" except the rules added below.
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.
Thanks for the clarification. Would you add a comment here describing that?
src/stdatamodels/fits_support.py
Outdated
|
||
Parameters | ||
---------- | ||
hdulist : weakref.ReferenceType |
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.
Is this a weakref? From the usage here it looks to be an HDUList proper:
stdatamodels/src/stdatamodels/fits_support.py
Line 216 in 0d6c26d
hdu = get_hdu(hdulist, hdu_name, index=index) |
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.
you're right it's a HDUlist, will update
src/stdatamodels/fits_support.py
Outdated
@@ -742,7 +813,25 @@ def from_fits(hdulist, schema, context, skip_fits_update=None, **kwargs): | |||
|
|||
def from_fits_asdf(hdulist, ignore_unrecognized_tag=False, **kwargs): | |||
""" | |||
Wrap asdf call to extract optional arguments | |||
Wrap asdf call to extract optional arguments. |
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.
I'm not sure this docstring summary makes sense any more. This is much more than a "wrap".
Wrap asdf call to extract optional arguments. | |
Open the ASDF extension from a FITS hdulist. | |
If the ASDF extension doesn't exist a new asdf.AsdfFile | |
instance will be returned. |
src/stdatamodels/fits_support.py
Outdated
@@ -911,6 +1011,19 @@ def fits_hash(hdulist): | |||
|
|||
|
|||
def get_short_doc(schema): | |||
""" | |||
Get the short description from the schema. |
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.
Get the short description from the schema. | |
Combine the title and description of a schema. |
Does this need a docstring? Can we instead make it private? The code seems messy and writing a docstring that describes the behavior would make this docstring even longer (and it's already longer than the code).
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.
yeah I think it's fine to make private, will do
src/stdatamodels/properties.py
Outdated
@@ -330,6 +354,8 @@ def instance(self): | |||
|
|||
|
|||
class ObjectNode(Node): | |||
"""A schema-validated dictionary-like structure.""" |
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.
"""A schema-validated dictionary-like structure.""" | |
"""A dictionary-like Node.""" |
src/stdatamodels/properties.py
Outdated
@@ -410,6 +436,8 @@ def items(self): | |||
|
|||
|
|||
class ListNode(Node): | |||
"""A list of schema-validated objects.""" |
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.
"""A list of schema-validated objects.""" | |
"""A list-like Node.""" |
src/stdatamodels/properties.py
Outdated
@@ -144,9 +154,21 @@ def _as_fitsrec(val): | |||
|
|||
def _get_schema_type(schema): | |||
""" | |||
Find the type of a schema and its subschemas. |
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.
Find the type of a schema and its subschemas. | |
Find the type or types used by a schema. |
src/stdatamodels/properties.py
Outdated
schema_type : str | ||
The type of the schema, or 'mixed' if the schema has multiple types. |
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.
schema_type : str | |
The type of the schema, or 'mixed' if the schema has multiple types. | |
str | |
The type used by a schema or 'mixed' if the schema has multiple types. |
src/stdatamodels/model_base.py
Outdated
""" | ||
Re-validate the model instance against its schema | ||
""" | ||
"""Re-validate the model instance against its schema.""" |
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.
"""Re-validate the model instance against its schema.""" | |
"""Validate the model instance against its schema.""" |
d89463b
to
21e9014
Compare
21e9014
to
5331100
Compare
Resolves JP-3885
Closes spacetelescope/jwst#9182
This PR turns on the Ruff "D" rules and numpydoc-validation pre-commit hook in order to ensure that all docstrings in stdatamodels follow the same style as jwst.
In order to bring the repository into compliance, I had to add a lot of brand-new docstrings to specific reference models, and these were not always models that I understand very well - during review, please pay special attention to these.
A few docstrings, specifically in
wcs_ref_models.py
, remain that I couldn't easily figure out how to populate because I didn't know enough about how the distortion models work. Hopefully one of the reviewers can provide clarity there.Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)jwst
regression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>"
)news fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.misc.rst
: infrastructure or miscellaneous change