|
30 | 30 | get_final_base, |
31 | 31 | get_newtype_base, |
32 | 32 | get_origin, |
33 | | - get_type_alias_base, |
34 | 33 | has, |
35 | 34 | has_with_generic, |
36 | 35 | is_annotated, |
|
48 | 47 | is_protocol, |
49 | 48 | is_sequence, |
50 | 49 | is_tuple, |
51 | | - is_type_alias, |
52 | 50 | is_typeddict, |
53 | 51 | is_union_type, |
54 | 52 | signature, |
|
92 | 90 | from .gen.typeddicts import make_dict_structure_fn as make_typeddict_dict_struct_fn |
93 | 91 | from .gen.typeddicts import make_dict_unstructure_fn as make_typeddict_dict_unstruct_fn |
94 | 92 | from .literals import is_literal_containing_enums |
| 93 | +from .typealiases import ( |
| 94 | + get_type_alias_base, |
| 95 | + is_type_alias, |
| 96 | + type_alias_structure_factory, |
| 97 | +) |
95 | 98 | from .types import SimpleStructureHook |
96 | 99 |
|
97 | 100 | __all__ = ["UnstructureStrategy", "BaseConverter", "Converter", "GenConverter"] |
@@ -259,7 +262,7 @@ def __init__( |
259 | 262 | ), |
260 | 263 | (is_generic_attrs, self._gen_structure_generic, True), |
261 | 264 | (lambda t: get_newtype_base(t) is not None, self._structure_newtype), |
262 | | - (is_type_alias, self._find_type_alias_structure_hook, True), |
| 265 | + (is_type_alias, type_alias_structure_factory, "extended"), |
263 | 266 | ( |
264 | 267 | lambda t: get_final_base(t) is not None, |
265 | 268 | self._structure_final_factory, |
@@ -699,14 +702,6 @@ def _structure_newtype(self, val: UnstructuredValue, type) -> StructuredValue: |
699 | 702 | base = get_newtype_base(type) |
700 | 703 | return self.get_structure_hook(base)(val, base) |
701 | 704 |
|
702 | | - def _find_type_alias_structure_hook(self, type: Any) -> StructureHook: |
703 | | - base = get_type_alias_base(type) |
704 | | - res = self.get_structure_hook(base) |
705 | | - if res == self._structure_call: |
706 | | - # we need to replace the type arg of `structure_call` |
707 | | - return lambda v, _, __base=base: __base(v) |
708 | | - return lambda v, _, __base=base: res(v, __base) |
709 | | - |
710 | 705 | def _structure_final_factory(self, type): |
711 | 706 | base = get_final_base(type) |
712 | 707 | res = self.get_structure_hook(base) |
|
0 commit comments