Improve typechecking#2541
Merged
VeckoTheGecko merged 15 commits intoParcels-code:mainfrom Mar 10, 2026
Merged
Conversation
…init__ return type - Remove 8 unused `# type: ignore` directives from _compat.py, particlefile.py, and utils/interpolation.py (now redundant with ty) - Fix UxGrid.__init__ return annotation from UxGrid to None Co-authored-by: Claude <noreply@anthropic.com>
Its already handled via runtime validation internally
Here we just rely on the runtime checking - this is unsanitised inputs anyway
2bd04e8 to
22f118d
Compare
VeckoTheGecko
commented
Mar 10, 2026
Comment on lines
-50
to
+65
| def vectorfield_repr(fieldset: FieldSet, from_fieldset_repr=False) -> str: | ||
| def vectorfield_repr(vector_field: VectorField, from_fieldset_repr=False) -> str: | ||
| """Return a pretty repr for VectorField""" | ||
| out = f"""<{type(fieldset).__name__} {fieldset.name!r}> | ||
| out = f"""<{type(vector_field).__name__} {vector_field.name!r}> | ||
| Parcels attributes: | ||
| name : {fieldset.name!r} | ||
| vector_interp_method : {fieldset.vector_interp_method!r} | ||
| vector_type : {fieldset.vector_type!r} | ||
| {field_repr(fieldset.U, level=1) if not from_fieldset_repr else ""} | ||
| {field_repr(fieldset.V, level=1) if not from_fieldset_repr else ""} | ||
| {field_repr(fieldset.W, level=1) if not from_fieldset_repr and fieldset.W else ""}""" | ||
| name : {vector_field.name!r} | ||
| vector_interp_method : {vector_field.vector_interp_method!r} | ||
| vector_type : {vector_field.vector_type!r} | ||
| {field_repr(vector_field.U, level=1) if not from_fieldset_repr else ""} | ||
| {field_repr(vector_field.V, level=1) if not from_fieldset_repr else ""} | ||
| {field_repr(vector_field.W, level=1) if not from_fieldset_repr and vector_field.W else ""}""" |
Contributor
Author
There was a problem hiding this comment.
quick win that was flagged by the typechecking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supercedes #2422
This PR adds a bunch of type annotations to the codebase, and centralises a lot of the types that are shared between files to
parcels._typing(which in some places is imported asptypingwhich i think is a nice alias).