More annotations in Dataset#3112
Conversation
| from .dataarray import DataArray | ||
| from .dataset import Dataset | ||
| from .dataarray import DataArray # noqa: F811 | ||
| from .dataset import Dataset # noqa: F811 |
There was a problem hiding this comment.
This is a workaround to a flake8 limitation https://gitlab.com/pycqa/flake8/issues/553
| elif isinstance(dim, Mapping): | ||
| # We're later going to modify dim in place; don't tamper with | ||
| # the input | ||
| dim = OrderedDict(dim) |
There was a problem hiding this comment.
Fixed bug where dim was modified in place, tainting the input variable. Also, fixed crash if the input dim is a read-only mapping.
Codecov Report
@@ Coverage Diff @@
## master #3112 +/- ##
==========================================
- Coverage 95.98% 95.94% -0.05%
==========================================
Files 63 63
Lines 12802 12816 +14
==========================================
+ Hits 12288 12296 +8
- Misses 514 520 +6 |
| append: bool = False, | ||
| inplace: bool = None, | ||
| **indexes_kwargs: Union[Hashable, Sequence[Hashable]] | ||
| ) -> 'Dataset': |
There was a problem hiding this comment.
Worth noting the behaviour is inconsistent with DataArray and pandas, which return None when inplace=True. Changing it however would benefit nobody and would break stuff.
|
@shoyer @max-sixty ready for review and merge |
| indexes: Mapping[Hashable, Union[Hashable, Sequence[Hashable]]] = None, | ||
| append: bool = False, | ||
| inplace: bool = None, | ||
| **indexes_kwargs: Union[Hashable, Sequence[Hashable]] |
There was a problem hiding this comment.
I'm guessing this is fine because mypy passes - my original thought was whether this should be Optional[Mapping] given it was either None or a dict?
There was a problem hiding this comment.
As of mypy 0.701, x: MyType = None and x: Optional[MyType] = None are the same.
from typing import Optional
def f1(x: int = None) -> None:
pass
def f2(x: Optional[int] = None) -> None:
pass
def f3(x: int = 1) -> None:
pass
def f4(x: Optional[int] = 1) -> None:
pass
f1()
f2()
f3()
f4()
f1(1)
f2(1)
f3(1)
f4(1)
f1(None)
f2(None)
f3(None)
f4(None)mypy output:
test_mypy.py:27: error: Argument 1 to "f3" has incompatible type "None"; expected "int"
There was a problem hiding this comment.
@max-sixty I did a generalised cleanup of all already existing cases; I find it's much more readable now
| self, | ||
| dims_or_levels: Union[Hashable, Sequence[Hashable]], | ||
| drop: bool = False, | ||
| inplace: bool = None, |
There was a problem hiding this comment.
inplace should go away soon so shouldn't matter... but should this be Optional[bool] given the default is None?
| Variable, | ||
| Tuple[Hashable, Any], | ||
| Tuple[Sequence[Hashable], Any], | ||
| ] |
|
Hello @crusaderky! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-07-24 22:54:48 UTC |
|
Great! Agree re |
|
@shoyer this is ready for merge unless there are comments |
| [mypy-xarray] | ||
| ignore_missing_imports = True | ||
|
|
||
| By `Guido Imperiale <https://github.com/crusaderky>`_ |
There was a problem hiding this comment.
Let's move this up to 0.12.4?
|
Thanks @crusaderky ! I think fine to merge given we've both reviewed |
|
+1 please go ahead without me!
…On Wed, Jul 24, 2019 at 9:53 AM Maximilian Roos ***@***.***> wrote:
Thanks @crusaderky <https://github.com/crusaderky> ! I think fine to
merge given we've both reviewed
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3112?email_source=notifications&email_token=AAJJFVQMF2SAWWTI66BFMGDQBCCJLA5CNFSM4IDA3ET2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2W6OCY#issuecomment-514713355>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJJFVR5RRGF4CGOGIDDU63QBCCJLANCNFSM4IDA3ETQ>
.
|
|
@max-sixty @shoyer can we merge please? |
|
Sorry @crusaderky - we were all waiting on each other! My mistake |
|
Thanks again for the PR |
* master: More annotations in Dataset (pydata#3112) Hotfix for case of combining identical non-monotonic coords (pydata#3151) changed url for rasterio network test (pydata#3162)
* master: (68 commits) enable sphinx.ext.napoleon (pydata#3180) remove type annotations from autodoc method signatures (pydata#3179) Fix regression: IndexVariable.copy(deep=True) casts dtype=U to object (pydata#3095) Fix distributed.Client.compute applied to DataArray (pydata#3173) More annotations in Dataset (pydata#3112) Hotfix for case of combining identical non-monotonic coords (pydata#3151) changed url for rasterio network test (pydata#3162) to_zarr(append_dim='dim0') doesn't need mode='a' (pydata#3123) BUG: fix+test groupby on empty DataArray raises StopIteration (pydata#3156) Temporarily remove pynio from py36 CI build (pydata#3157) missing 'about' field (pydata#3146) Fix h5py version printing (pydata#3145) Remove the matplotlib=3.0 constraint from py36.yml (pydata#3143) disable codecov comments (pydata#3140) Merge broadcast_like docstrings, analyze implementation problem (pydata#3130) Update whats-new for pydata#3125 and pydata#2334 (pydata#3135) Fix tests on big-endian systems (pydata#3125) XFAIL tests failing on ARM (pydata#2334) Add broadcast_like. (pydata#3086) Better docs and errors about expand_dims() view (pydata#3114) ...
No description provided.