Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens static typing support across earthkit-climate as a follow-up to #43, adding mypy configuration, improving type annotations, and marking the package as PEP 561 typed.
Changes:
- Add PEP 561
py.typedmarker (and packaging + test coverage for it). - Introduce/strengthen typing via
TypeAliasandProtocolin core conversion/wrapper/provenance utilities. - Configure mypy in
pyproject.tomland update the pixi task to run mypy againstsrcandtests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_00_version.py | Switch import style and add a test asserting py.typed presence. |
| src/earthkit/climate/utils/provenance.py | Add a Protocol for indicator typing and tighten the add_indicator_provenance signature. |
| src/earthkit/climate/utils/conversions.py | Replace legacy typing constructs with TypeAlias, built-in generics, and collections.abc. |
| src/earthkit/climate/py.typed | Add PEP 561 marker file. |
| src/earthkit/climate/indicators/init.py | Export indicator submodules via explicit imports and __all__. |
| src/earthkit/climate/api/wrapper.py | Add Protocol/type aliases for wrapped xclim indicators and improve annotations. |
| src/earthkit/climate/init.py | Normalize imports and fix __all__ to use string exports. |
| pyproject.toml | Add mypy config, include py.typed as package data, and add pandas-stubs to dev deps. |
| pixi.toml | Add pandas-stubs for dev and update the type-check task. |
| .pre-commit-config.yaml | Remove redundant ruff line-length arg (now configured in pyproject.toml). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| def test_py_typed_marker_present() -> None: | ||
| assert Path(climate.__file__).with_name("py.typed").is_file() |
Comment on lines
+21
to
+24
| class IndicatorWithCompute(Protocol): | ||
| """Indicator-like object with a callable interface and a compute method.""" | ||
|
|
||
| def compute(self, *args: Any, **kwargs: Any) -> object: ... |
Comment on lines
+32
to
35
| def wrap_xclim_indicator(xclim_fn: XclimIndicator) -> Callable[..., conversions.EarthkitData]: | ||
| """ | ||
| Wraps an xclim indicator to handle Earthkit inputs and unit alignment. | ||
|
|
Comment on lines
+16
to
+19
| import earthkit.climate.indicators.precipitation as precipitation | ||
| import earthkit.climate.indicators.temperature as temperature | ||
|
|
||
| __all__ = ["precipitation", "temperature"] |
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.
Description
As a followup on #43 the type checking is hardened a bit.
Contributor Declaration
By opening this pull request, I affirm the following: