Skip to content

Commit f22208e

Browse files
committed
post-#1043 type hints
1 parent fa871c5 commit f22208e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

tiled/client/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from copy import copy, deepcopy
33
from dataclasses import asdict
44
from pathlib import Path
5-
from typing import Dict, List, Union
5+
from typing import Dict, List, Optional, Union
66
from urllib.parse import parse_qs, urlparse
77

88
import json_merge_patch
@@ -11,6 +11,7 @@
1111
from httpx import URL
1212

1313
from tiled.client.context import Context
14+
from tiled.structures.root import Structure
1415

1516
from ..structures.core import STRUCTURE_TYPES, Spec, StructureFamily
1617
from ..structures.data_source import DataSource
@@ -131,8 +132,8 @@ def __init__(
131132
*,
132133
item,
133134
structure_clients,
134-
structure=None,
135-
include_data_sources=False,
135+
structure: Optional[Structure] = None,
136+
include_data_sources: bool = False,
136137
):
137138
self._context = context
138139
self._item = item

tiled/server/schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from pydantic_core import PydanticCustomError
1111
from typing_extensions import Annotated, TypedDict
1212

13+
from tiled.structures.root import Structure
14+
1315
from ..structures.array import ArrayStructure
1416
from ..structures.awkward import AwkwardStructure
1517
from ..structures.core import STRUCTURE_TYPES, StructureFamily
@@ -24,7 +26,7 @@
2426
DataT = TypeVar("DataT")
2527
LinksT = TypeVar("LinksT")
2628
MetaT = TypeVar("MetaT")
27-
StructureT = TypeVar("StructureT")
29+
StructureT = TypeVar("StructureT", bound=Structure)
2830

2931

3032
MAX_ALLOWED_SPECS = 20

tiled/structures/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from dataclasses import asdict, dataclass
1010
from typing import Dict, Optional
1111

12+
from tiled.structures.root import Structure
13+
1214
from ..utils import OneShotCachedMap
1315

1416

@@ -47,8 +49,7 @@ def dict(self) -> Dict[str, Optional[str]]:
4749
model_dump = dict # For easy interoperability with pydantic 2.x models
4850

4951

50-
# TODO: make type[Structure] after #1036
51-
STRUCTURE_TYPES = OneShotCachedMap[StructureFamily, type](
52+
STRUCTURE_TYPES = OneShotCachedMap[StructureFamily, type[Structure]](
5253
{
5354
StructureFamily.array: lambda: importlib.import_module(
5455
"...structures.array", StructureFamily.__module__

0 commit comments

Comments
 (0)