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

mypy implementation for adapters in tiled #700

Merged
merged 45 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fe79576
some more changes
Apr 4, 2024
1038553
typed zarr.py
Apr 4, 2024
7595639
typed tiff.py
Apr 4, 2024
06ac19c
xarray.py typed
Apr 4, 2024
a80caba
some more typing added
Apr 5, 2024
786a275
some more typing. still few problems in mapping.py
Apr 5, 2024
82a3d01
more typing
Apr 5, 2024
c5ac22b
still 1 mypy problem left
Apr 8, 2024
1a0b167
docstring skeletons added
Apr 8, 2024
2265002
some more improvement
Apr 9, 2024
c6358fd
solved some docs build problems
Apr 9, 2024
2777e3c
few more changes
Apr 9, 2024
84e64ac
change type_alliases.py
Apr 9, 2024
9a9486f
some more changes
Apr 9, 2024
64a3fdb
some more changes
Apr 9, 2024
8c32d0b
update python to 3.11 in doc compilation
Apr 10, 2024
090eda3
fixed failing tests
Apr 10, 2024
1f4536a
Add protocols
danielballan Apr 10, 2024
6a20cb9
change docs python to 3.10
Apr 10, 2024
be14c77
preliminary addressing to the comments
Apr 12, 2024
8509083
some tests for protocols
Apr 15, 2024
1be2018
some corrections in protocols tests
Apr 15, 2024
9331763
fix small bug in test_protocols.py
Apr 15, 2024
edf4e1f
try to solve EllipsisType that only exists in python 3.10
Apr 15, 2024
9c7aa41
change python version check
Apr 15, 2024
b066f41
some more fix
Apr 15, 2024
5c05e13
Bump Python version of docs build.
danielballan Apr 23, 2024
ed2a731
tests
Apr 24, 2024
95ffb51
some more unit tests for protocols
Apr 25, 2024
4d1f6b0
add accesspolicy protocol tests
Apr 25, 2024
bb0f108
few more fixes
Apr 25, 2024
809089c
python 3.8 MutableMapping problem: try to replacse with the one from …
Apr 26, 2024
126eed2
try to change collections.abc.MApping with typing.Mapping if python<3.8
Apr 26, 2024
b268500
small fixes for typing errors appeared in python 3.8
Apr 26, 2024
e9dfa6d
one more typing fix for python 3.8
Apr 26, 2024
07f717a
some more fix python3.8
Apr 26, 2024
6f4e773
Type awkward buffers dict more strictly
danielballan Apr 26, 2024
7038db5
Tighten typing on data_uris.
danielballan Apr 26, 2024
9f10eb9
Fix typing of partition parameter in read_partition.
danielballan Apr 26, 2024
d923f4f
Zarr accepts array data, not dataframe/tabular.
danielballan Apr 26, 2024
557e32f
Remove commented unused code
danielballan Apr 26, 2024
7d4a34e
Fix typo
danielballan Apr 26, 2024
d000794
Fix type of partition
danielballan Apr 26, 2024
453b807
added a changelog entry
Apr 26, 2024
e863422
Make python-version consistent for docs
danielballan Apr 26, 2024
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
Prev Previous commit
Next Next commit
few more changes
Seher Karakuzu authored and danielballan committed Apr 26, 2024
commit 2777e3c95dbd098d9bec03eca85979c48933175a
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ disallow_incomplete_defs = False

[mypy-tiled.adapters.*]
ignore_errors = False
ignore_missing_imports = False
check_untyped_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_calls = True
warn_return_any = True
disallow_untyped_decorators = True
5 changes: 2 additions & 3 deletions tiled/adapters/array.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, List, Optional, Tuple, Union

import dask.array
from numpy import dtype, ndarray
from numpy.typing import NDArray

from ..access_policies import DummyAccessPolicy, SimpleAccessPolicy
@@ -127,7 +126,7 @@ def structure(self) -> ArrayStructure:
"""
return self._structure

def read(self, slice: Optional[slice]) -> ndarray[Any, dtype[Any]]:
def read(self, slice: Optional[slice]) -> NDArray[Any]:
"""

Parameters
@@ -149,7 +148,7 @@ def read_block(
self,
block: Tuple[int, ...],
slice: slice,
) -> ndarray[Any, dtype[Any]]:
) -> NDArray[Any]:
"""

Parameters
3 changes: 2 additions & 1 deletion tiled/adapters/mapping.py
Original file line number Diff line number Diff line change
@@ -420,9 +420,10 @@ def sort(self, sorting: SortingItem) -> "MapAdapter":
mapping = dict(
sorted(
mapping.items(),
key=lambda item: item[1].metadata().get(key, _HIGH_SORTER),
key=lambda item: item[1].metadata().get(key, _HIGH_SORTER), # type: ignore
)
)

if direction < 0:
# TODO In Python 3.8 dict items should be reservible
# but I have seen errors in the wild that I could not
10 changes: 4 additions & 6 deletions tiled/adapters/type_alliases.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# JSON = dict[str, "JSON"] | list["JSON"] | str | int | float | bool | None
# from typing import Any
from typing import Any, Dict, List, Union
from typing import Dict, List, TypeAlias, Union

# JSON = dict[str, "JSON"] | list["JSON"]
JSONValue = Union[str, int, float, bool, None, Dict[str, Any], List[Any]]
JSON = Union[Dict[str, JSONValue], List[JSONValue]]
JSON: TypeAlias = Dict[
str, Union[str, int, float, bool, Dict[str, "JSON"], List["JSON"]]
]
2 changes: 1 addition & 1 deletion tiled/adapters/zarr.py
Original file line number Diff line number Diff line change
@@ -237,7 +237,7 @@ def access_policy(self) -> Optional[Union[SimpleAccessPolicy, DummyAccessPolicy]
"""
return self._access_policy

def metadata(self) -> JSON:
def metadata(self) -> Any:
"""

Returns