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

Use strict type hinting for namedarray #8241

Merged
merged 114 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
b894d25
Disallow untyped defs in namedarray
Illviljan Sep 27, 2023
895c2cb
Just use strict instead
Illviljan Sep 27, 2023
15a2a8b
Update pyproject.toml
Illviljan Sep 27, 2023
89c8fea
Test explicit list instead.
Illviljan Sep 27, 2023
4e10650
Update pyproject.toml
Illviljan Sep 27, 2023
fc7f69a
Update pyproject.toml
Illviljan Sep 27, 2023
43f4e20
Update pyproject.toml
Illviljan Sep 27, 2023
e6147d3
Merge branch 'main' into disallow_untyped_defs
Illviljan Sep 28, 2023
b84b1bc
Merge branch 'main' into disallow_untyped_defs
Illviljan Sep 28, 2023
7cb3a09
Update utils.py
Illviljan Sep 28, 2023
4a83aa4
Update core.py
Illviljan Sep 28, 2023
7ad7634
getmaskarray isn't typed yet
Illviljan Sep 28, 2023
cebd1eb
Update core.py
Illviljan Sep 28, 2023
71a942b
add _Array protocol
Illviljan Sep 28, 2023
4cdbed5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 28, 2023
c80ff30
Update utils.py
Illviljan Sep 28, 2023
2e84c31
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Sep 28, 2023
f6c6f44
Update utils.py
Illviljan Sep 28, 2023
4b897eb
Update utils.py
Illviljan Sep 28, 2023
7a5cb43
Merge branch 'main' into disallow_untyped_defs
Illviljan Sep 28, 2023
7081ee1
Update utils.py
Illviljan Sep 28, 2023
87958d9
Update utils.py
Illviljan Sep 28, 2023
f913206
Update utils.py
Illviljan Sep 28, 2023
3b0c122
Update utils.py
Illviljan Sep 28, 2023
027f300
Update utils.py
Illviljan Sep 28, 2023
23ec9fe
Update utils.py
Illviljan Sep 28, 2023
d94b766
Update utils.py
Illviljan Sep 28, 2023
c353336
Update utils.py
Illviljan Sep 28, 2023
5e26eba
Update test_namedarray.py
Illviljan Sep 28, 2023
c5a9594
Update utils.py
Illviljan Sep 28, 2023
ecb50c0
Update test_namedarray.py
Illviljan Sep 28, 2023
9ab9dae
Update test_namedarray.py
Illviljan Sep 28, 2023
19b3304
Merge branch 'main' into disallow_untyped_defs
Illviljan Sep 29, 2023
41bd67c
Update utils.py
Illviljan Sep 29, 2023
5f58cee
Update utils.py
Illviljan Sep 30, 2023
7f1a94e
Update utils.py
Illviljan Sep 30, 2023
685ca7c
Update core.py
Illviljan Sep 30, 2023
7aa2f57
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2023
99b0aca
Update utils.py
Illviljan Sep 30, 2023
84b6894
Update core.py
Illviljan Sep 30, 2023
08d11ef
Update test_namedarray.py
Illviljan Sep 30, 2023
196a5c6
Update test_namedarray.py
Illviljan Sep 30, 2023
07e3085
Update test_namedarray.py
Illviljan Sep 30, 2023
707f244
Update utils.py
Illviljan Sep 30, 2023
a3901bc
Update core.py
Illviljan Sep 30, 2023
df13d47
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2023
f76aeb1
Update core.py
Illviljan Sep 30, 2023
cce278c
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Sep 30, 2023
3865264
Update core.py
Illviljan Sep 30, 2023
b61d9a8
Update utils.py
Illviljan Sep 30, 2023
4dec3ca
Update core.py
Illviljan Oct 1, 2023
26ac902
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 1, 2023
9d23245
Update core.py
Illviljan Oct 1, 2023
1f1a25d
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Oct 1, 2023
d8007e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 1, 2023
762e808
Merge branch 'main' into disallow_untyped_defs
Illviljan Oct 1, 2023
459b38a
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Oct 1, 2023
1f93f5f
Update core.py
Illviljan Oct 1, 2023
b2570dd
Update test_namedarray.py
Illviljan Oct 1, 2023
6835c09
Update utils.py
Illviljan Oct 1, 2023
1bac4af
Update pyproject.toml
Illviljan Oct 1, 2023
5d72861
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 1, 2023
ebf4752
Update core.py
Illviljan Oct 1, 2023
6c8fac9
Update utils.py
Illviljan Oct 1, 2023
ee49c5e
Update xarray/namedarray/utils.py
Illviljan Oct 1, 2023
5de4142
Update utils.py
Illviljan Oct 1, 2023
99bf8aa
Update core.py
Illviljan Oct 1, 2023
fa41cbe
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Oct 1, 2023
b27145e
Update utils.py
Illviljan Oct 1, 2023
7f262d5
Update core.py
Illviljan Oct 1, 2023
401a93a
Update utils.py
Illviljan Oct 1, 2023
bcda5a4
Update core.py
Illviljan Oct 1, 2023
2535a5f
Update core.py
Illviljan Oct 1, 2023
2c5b49d
Update core.py
Illviljan Oct 1, 2023
9d29827
Update test_namedarray.py
Illviljan Oct 1, 2023
2fba5a9
Update utils.py
Illviljan Oct 1, 2023
80842ea
Update core.py
Illviljan Oct 1, 2023
cf8d5cc
Update utils.py
Illviljan Oct 1, 2023
32439fe
Update test_namedarray.py
Illviljan Oct 1, 2023
946bd3d
Update test_namedarray.py
Illviljan Oct 1, 2023
130c894
Update core.py
Illviljan Oct 1, 2023
e0064b9
Update parallel.py
Illviljan Oct 1, 2023
fec9f1b
Update utils.py
Illviljan Oct 1, 2023
877f0f1
fixes
Illviljan Oct 1, 2023
a5eddb1
Update utils.py
Illviljan Oct 1, 2023
2194715
Update utils.py
Illviljan Oct 1, 2023
77e05f2
ignores
Illviljan Oct 1, 2023
1348df6
Update xarray/namedarray/utils.py
Illviljan Oct 2, 2023
025e9cc
Update xarray/namedarray/utils.py
Illviljan Oct 2, 2023
2305216
Update core.py
Illviljan Oct 2, 2023
13c8953
Update test_namedarray.py
Illviljan Oct 2, 2023
5559548
Update core.py
Illviljan Oct 2, 2023
a177ce7
Update core.py
Illviljan Oct 2, 2023
ca7ee37
Update core.py
Illviljan Oct 2, 2023
ce77930
Update core.py
Illviljan Oct 2, 2023
99f6c9b
Update test_namedarray.py
Illviljan Oct 2, 2023
0fa4fd3
Update core.py
Illviljan Oct 2, 2023
5b98dd5
Update test_namedarray.py
Illviljan Oct 2, 2023
56a7755
import specific type functions
Illviljan Oct 2, 2023
b321a84
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2023
6a33331
Update core.py
Illviljan Oct 2, 2023
863ed1d
Update core.py
Illviljan Oct 2, 2023
11b36fa
Update core.py
Illviljan Oct 2, 2023
2bd6f8c
Try chunkedarray instead
Illviljan Oct 2, 2023
476dda2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2023
27c18b8
fixes
Illviljan Oct 2, 2023
931659f
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Oct 2, 2023
c2a1fb7
Update core.py
Illviljan Oct 2, 2023
892e83d
Update core.py
Illviljan Oct 2, 2023
58266c4
Update core.py
Illviljan Oct 2, 2023
00cba3d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2023
114c45c
Update core.py
Illviljan Oct 2, 2023
c414c0a
Merge branch 'disallow_untyped_defs' of https://github.com/Illviljan/…
Illviljan Oct 2, 2023
ec9c173
Merge branch 'main' into disallow_untyped_defs
andersy005 Oct 3, 2023
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
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module = [
"cftime.*",
"cubed.*",
"cupy.*",
"dask.types.*",
"fsspec.*",
"h5netcdf.*",
"h5py.*",
Expand Down Expand Up @@ -162,6 +163,41 @@ module = [
"xarray.tests.test_weighted",
]

# Use strict = true whenever namedarray has become standalone. In the meantime
# don't forget to add all new files related to namedarray here:
# ref: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
[[tool.mypy.overrides]]
# Start off with these
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true

# Getting these passing should be easy
strict_equality = true
strict_concatenate = true

# Strongly recommend enabling this one as soon as you can
check_untyped_defs = true

# These shouldn't be too much additional work, but may be tricky to
# get passing if you use a lot of untyped libraries
disallow_subclassing_any = true
disallow_untyped_decorators = true
disallow_any_generics = true

# These next few are various gradations of forcing use of type annotations
disallow_untyped_calls = true
disallow_incomplete_defs = true
disallow_untyped_defs = true

# This one isn't too hard to get passing, but return on investment is lower
no_implicit_reexport = true

# This one can be tricky to get passing if you use a lot of untyped libraries
warn_return_any = true

module = ["xarray.namedarray.*", "xarray.tests.test_namedarray"]

[tool.ruff]
builtins = ["ellipsis"]
exclude = [
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def subset_dataset_to_block(
for dim in variable.dims:
chunk = chunk[chunk_index[dim]]

chunk_variable_task = (f"{name}-{gname}-{chunk[0]}",) + chunk_tuple
chunk_variable_task = (f"{name}-{gname}-{chunk[0]!r}",) + chunk_tuple
graph[chunk_variable_task] = (
tuple,
[variable.dims, chunk, variable.attrs],
Expand Down
Loading
Loading