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
some more changes
Seher Karakuzu authored and danielballan committed Apr 26, 2024
commit 9a9486fe0f554f40190b69c9b9797a3e67faedbb
2 changes: 1 addition & 1 deletion tiled/adapters/awkward_buffers.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
import awkward.forms

from ..access_policies import DummyAccessPolicy, SimpleAccessPolicy
from ..server.pydantic_awkward import AwkwardStructure
from ..structures.awkward import AwkwardStructure
from ..structures.core import Spec, StructureFamily
from ..utils import path_from_uri
from .awkward import AwkwardAdapter
8 changes: 4 additions & 4 deletions tiled/adapters/hdf5.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
from ..access_policies import DummyAccessPolicy, SimpleAccessPolicy
from ..adapters.utils import IndexersMixin
from ..iterviews import ItemsView, KeysView, ValuesView
from ..server.schemas import NodeStructure
from ..structures.array import ArrayStructure
from ..structures.core import Spec, StructureFamily
from ..structures.table import TableStructure
from ..utils import node_repr, path_from_uri
@@ -73,7 +73,7 @@ def __init__(
self,
node: Any,
*,
structure: Optional[NodeStructure] = None,
structure: Optional[ArrayStructure] = None,
metadata: Optional[JSON] = None,
specs: Optional[List[Spec]] = None,
access_policy: Optional[Union[SimpleAccessPolicy, DummyAccessPolicy]] = None,
@@ -129,7 +129,7 @@ def from_uri(
cls,
data_uri: Union[str, List[str]],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data_uri: Union[str, List[str]],
data_uri: str,

*,
structure: Optional[NodeStructure] = None,
structure: Optional[ArrayStructure] = None,
metadata: Optional[JSON] = None,
swmr: bool = SWMR_DEFAULT,
libver: str = "latest",
@@ -369,7 +369,7 @@ def inlined_contents_enabled(self, depth: int) -> bool:
def hdf5_lookup(
data_uri: Union[str, List[str]],
*,
structure: Optional[NodeStructure] = None,
structure: Optional[ArrayStructure] = None,
metadata: Optional[JSON] = None,
swmr: bool = SWMR_DEFAULT,
libver: str = "latest",
5 changes: 3 additions & 2 deletions tiled/adapters/mapping.py
Original file line number Diff line number Diff line change
@@ -24,8 +24,9 @@
StructureFamilyQuery,
)
from ..query_registration import QueryTranslationRegistry
from ..server.schemas import NodeStructure, SortingItem
from ..server.schemas import SortingItem
from ..structures.core import Spec, StructureFamily
from ..structures.table import TableStructure
from ..utils import UNCHANGED, Sentinel
from .table import TableAdapter
from .type_alliases import JSON
@@ -61,7 +62,7 @@ def __init__(
self,
mapping: dict[str, TableAdapter],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mapping: dict[str, TableAdapter],
mapping: dict[str, AnyAdapter],

*,
structure: Optional[NodeStructure] = None,
structure: Optional[TableStructure] = None,
metadata: Optional[JSON] = None,
sorting: Optional[List[SortingItem]] = None,
specs: Optional[List[Spec]] = None,
4 changes: 1 addition & 3 deletions tiled/adapters/type_alliases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

JSON= Dict[
str, Union[str, int, float, bool, Dict[str, "JSON"], List["JSON"]]
]
JSON = Dict[str, Union[str, int, float, bool, Dict[str, "JSON"], List["JSON"]]]
20 changes: 10 additions & 10 deletions tiled/adapters/zarr.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import collections.abc
import os
from types import EllipsisType
from typing import Any, Iterator, List, Optional, Tuple, Union
from typing import Any, Callable, Iterator, List, Optional, Tuple, Union

import dask
import pandas
@@ -14,9 +14,9 @@
from ..access_policies import DummyAccessPolicy, SimpleAccessPolicy
from ..adapters.utils import IndexersMixin
from ..iterviews import ItemsView, KeysView, ValuesView
from ..server.schemas import NodeStructure
from ..structures.array import ArrayStructure
from ..structures.core import Spec, StructureFamily
from ..structures.table import TableStructure
from ..utils import node_repr, path_from_uri
from .array import ArrayAdapter, slice_and_shape_from_block_and_chunks
from .type_alliases import JSON
@@ -25,7 +25,9 @@


def read_zarr(
data_uri: Union[str, List[str]], structure: Optional[NodeStructure], **kwargs: Any
data_uri: Union[str, List[str]],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data_uri: Union[str, List[str]],
data_uri: str,

structure: Optional[ArrayStructure],
**kwargs: Any,
) -> Union["ZarrGroupAdapter", ArrayAdapter]:
"""

@@ -101,7 +103,7 @@ def _stencil(self) -> Tuple[slice, ...]:
"""
return tuple(builtins.slice(0, dim) for dim in self.structure().shape)

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

Parameters
@@ -114,9 +116,7 @@ def read(self, slice: Optional[slice]) -> NDArray[Any]:
"""
return self._array[self._stencil()][slice]

def read_block(
self, block: Tuple[int, ...], slice: Optional[Union[slice, EllipsisType]]
) -> NDArray[Any]:
def read_block(self, block: Tuple[int, ...], slice: ...) -> NDArray[Any]:
"""

Parameters
@@ -138,7 +138,7 @@ def read_block(
def write(
self,
data: Union[dask.dataframe.DataFrame, pandas.DataFrame],
slice: Optional[Union[slice, EllipsisType]],
slice: ...,
) -> None:
"""

@@ -159,7 +159,7 @@ async def write_block(
self,
data: Union[dask.dataframe.DataFrame, pandas.DataFrame],
block: Tuple[int, ...],
slice: Optional[Union[slice, EllipsisType]],
slice: ...,
) -> None:
"""

@@ -193,7 +193,7 @@ def __init__(
self,
node: Any,
*,
structure: Optional[Union[NodeStructure, ArrayStructure]] = None,
structure: Optional[ArrayStructure] = None,
metadata: Optional[JSON] = None,
specs: Optional[List[Spec]] = None,
access_policy: Optional[Union[SimpleAccessPolicy, DummyAccessPolicy]] = None,
2 changes: 1 addition & 1 deletion tiled/server/pydantic_array.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ class BuiltinDtype(BaseModel):
__endianness_reverse_map = {"big": ">", "little": "<", "not_applicable": "|"}

@classmethod
def from_numpy_dtype(cls, dtype):
def from_numpy_dtype(cls, dtype) -> "BuiltinDtype":
return cls(
endianness=cls.__endianness_map[dtype.byteorder],
kind=Kind(dtype.kind),