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

typing annotations #692

Merged
merged 25 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@ repos:
rev: v5.6.4
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
- id: mypy
# `asv_bench` are copied from setup.cfg.
# `_typed_ops.py` is added since otherwise mypy will complain (but notably only in pre-commit)
exclude: "asv_bench"
additional_dependencies: [
# Type stubs
types-python-dateutil,
types-pkg_resources,
types-PyYAML,
types-pytz,
typing-extensions==3.10.0.0,
# Dependencies that are typed
numpy,
]
3 changes: 2 additions & 1 deletion ci/requirements/climpred-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ dependencies:
- black==19.10b0
- coveralls
- flake8
#- importlib_metadata
- mypy
- isort
- pre-commit
- pylint
- pytest
- pytest-cov
- pytest-sugar
- mypy_extensions
# Performance
- bottleneck
- numba
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- importlib_metadata
- matplotlib-base
- nbsphinx
- mypy_extensions
- nc-time-axis
- netcdf4
- sphinx
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/docs_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- sphinxcontrib-napoleon
- sphinx_rtd_theme
- sphinx-copybutton
- mypy_extensions
- toolz
- xarray>=0.16.1
- esmtools>=1.1.3
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/maximum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- pytest
- pytest-cov
- pytest-xdist
- mypy_extensions
- scipy
- xarray>=0.16.1
- xesmf
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/minimum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- scipy
- xarray>=0.16.1
- xskillscore>=0.0.18
- mypy_extensions
- pip:
- pytest-lazy-fixture
- -e ../..
5 changes: 4 additions & 1 deletion climpred/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ def warn_if_chunking_would_increase_performance(ds, crit_size_in_MB=100):
)


def _check_valid_reference(reference):
from typing import List, Optional, Union


def _check_valid_reference(reference: Optional[Union[List[str], str]]) -> List:
"""Enforce reference as list and check for valid entries."""
if reference is None:
reference = []
Expand Down
Loading