Skip to content

Commit 4cc0385

Browse files
committed
remove dead code and consolidate tests
1 parent bb7e84e commit 4cc0385

2 files changed

Lines changed: 80 additions & 293 deletions

File tree

src/zarr/core/type_check.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _type_name(tp: Any) -> str:
3838
"""Get a readable name for a type hint."""
3939
if isinstance(tp, type):
4040
return tp.__name__
41-
return getattr(tp, "__qualname__", None) or str(tp)
41+
return str(tp)
4242

4343

4444
def _is_typeddict_class(tp: object) -> bool:
@@ -48,44 +48,6 @@ def _is_typeddict_class(tp: object) -> bool:
4848
return isinstance(tp, type) and hasattr(tp, "__annotations__") and hasattr(tp, "__total__")
4949

5050

51-
def _substitute_typevars(tp: Any, type_map: dict[TypeVar, Any]) -> Any:
52-
"""
53-
Given a type and a mapping of typevars to types, substitute the typevars in the type.
54-
55-
This function will recurse into nested types.
56-
57-
Parameters
58-
----------
59-
tp : Any
60-
The type to substitute.
61-
type_map : dict[TypeVar, Any]
62-
A mapping of typevars to types.
63-
64-
Returns
65-
-------
66-
Any
67-
The substituted type.
68-
"""
69-
if isinstance(tp, TypeVar):
70-
return type_map.get(tp, tp)
71-
72-
origin = get_origin(tp)
73-
if origin is None:
74-
return tp
75-
76-
args = get_args(tp)
77-
if not args:
78-
return tp
79-
80-
new_args = tuple(_substitute_typevars(a, type_map) for a in args)
81-
try:
82-
return origin[new_args]
83-
except Exception:
84-
if len(new_args) == 1:
85-
return new_args[0]
86-
return tp
87-
88-
8951
def _find_generic_typeddict_base(cls: type) -> tuple[type | None, tuple[Any, ...] | None]:
9052
"""
9153
Find the base class of a generic TypedDict class.

0 commit comments

Comments
 (0)