-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type checking with mypy #2655
Type checking with mypy #2655
Conversation
The rest of the scientific Python stack doesn't seem to support type annotations yet, but that's OK -- we can use this incrementally in xarray when it seems appropriate, and may check a few bugs. I'm especially excited to use this for internal functions, where we don't always bother with full docstrings (e.g., what is the type of the ``variables`` argument?). This includes: 1. various minor fixes to ensure that "mypy xarray" passes. 2. adding "mypy xarray" to our lint check on Travis-CI. For reference, see "Using mypy with an existing codebase": https://mypy.readthedocs.io/en/stable/existing_code.html Question: are we OK with (2)? This means Travis-CI will fail if your code causes mypy to error.
Hello @shoyer! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on January 07, 2019 at 01:08 Hours UTC |
Re (2): Perhaps it would be better to have mypy as an optional test? Can you add some docs to the "contributing to xarray" section on how to annotate or link to some documentation so that contributors know where to look. |
I agree, let's experiment with keeping mypy optional for now. The error messages can definitely be a little confusing for non-experts. It should be pretty easy to fix regressions as they come up. I've added a brief note on mypy to the contributing docs and removed the Travis-CI check. |
I think this is good to merge now |
* upstream/master: xfail cftimeindex multiindex test (pydata#2669) DOC: refresh "Why xarray" and shorten top-level description (pydata#2657) Remove broken Travis-CI builds (pydata#2661) Type checking with mypy (pydata#2655) Added Coarsen (pydata#2612)
* master: Remove broken Travis-CI builds (pydata#2661) Type checking with mypy (pydata#2655) Added Coarsen (pydata#2612) Improve test for GH 2649 (pydata#2654) revise top-level package description (pydata#2430) Convert ref_date to UTC in encode_cf_datetime (pydata#2651) Change an `==` to an `is`. Fix tests so that this won't happen again. (pydata#2648) ENH: switch Dataset and DataArray to use explicit indexes (pydata#2639) Use pycodestyle for lint checks. (pydata#2642) Switch whats-new for 0.11.2 -> 0.11.3 DOC: document v0.11.2 release Use built-in interp for interpolation with resample (pydata#2640) BUG: pytest-runner no required for setup.py (pydata#2643)
The rest of the scientific Python stack doesn't seem to support type annotations yet, but that's OK -- we can use this incrementally in xarray when it seems appropriate, and may check a few bugs. I'm especially excited to use this for internal functions, where we don't always bother with full docstrings (e.g., what is the type of the
variables
argument?).This includes:
adding "mypy xarray" to our lint check on Travis-CI.For reference, see "Using mypy with an existing codebase":
https://mypy.readthedocs.io/en/stable/existing_code.html
Question: are we OK with (2)? This means Travis-CI will fail if your code causes mypy to error.