omlish 0.0.0.dev415__py3-none-any.whl → 0.0.0.dev417__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omlish/__about__.py +2 -2
- omlish/bootstrap/__init__.py +2 -2
- omlish/dataclasses/__init__.py +28 -14
- omlish/dataclasses/impl/processing/base.py +1 -1
- omlish/lang/__init__.py +486 -473
- omlish/lang/imports/proxyinit.py +161 -48
- omlish/lang/maybes.py +8 -0
- omlish/marshal/__init__.py +224 -203
- omlish/marshal/base/configs.py +18 -0
- omlish/marshal/base/contexts.py +23 -19
- omlish/marshal/base/overrides.py +26 -12
- omlish/marshal/base/registries.py +66 -16
- omlish/marshal/base/types.py +60 -8
- omlish/marshal/factories/invalidate.py +118 -0
- omlish/marshal/factories/moduleimport/__init__.py +0 -0
- omlish/marshal/factories/moduleimport/configs.py +26 -0
- omlish/marshal/factories/moduleimport/factories.py +114 -0
- omlish/marshal/factories/typecache.py +24 -4
- omlish/marshal/globals.py +52 -27
- omlish/marshal/polymorphism/metadata.py +2 -2
- omlish/marshal/standard.py +132 -65
- omlish/reflect/__init__.py +57 -47
- omlish/reflect/types.py +144 -15
- omlish/secrets/all.py +0 -9
- omlish/secrets/secrets.py +4 -6
- omlish/specs/jsonrpc/__init__.py +2 -2
- omlish/specs/jsonschema/__init__.py +2 -2
- omlish/specs/openapi/__init__.py +2 -2
- omlish/sql/queries/__init__.py +4 -2
- omlish/sql/tabledefs/__init__.py +2 -2
- omlish/typedvalues/__init__.py +2 -2
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/METADATA +14 -9
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/RECORD +43 -37
- /omlish/bootstrap/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/jsonrpc/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/jsonschema/{marshal.py → _marshal.py} +0 -0
- /omlish/specs/openapi/{marshal.py → _marshal.py} +0 -0
- /omlish/sql/queries/{marshal.py → _marshal.py} +0 -0
- /omlish/sql/tabledefs/{marshal.py → _marshal.py} +0 -0
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev415.dist-info → omlish-0.0.0.dev417.dist-info}/top_level.txt +0 -0
omlish/marshal/standard.py
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
"""
|
2
|
+
FIXME:
|
3
|
+
- this is gross and temporary
|
4
|
+
- move to global registry somehow
|
5
|
+
"""
|
6
|
+
import threading
|
1
7
|
import typing as ta
|
2
8
|
|
3
9
|
from .base.types import MarshalerFactory
|
@@ -16,6 +22,10 @@ from .composite.optionals import OptionalMarshalerFactory
|
|
16
22
|
from .composite.optionals import OptionalUnmarshalerFactory
|
17
23
|
from .composite.special import SequenceNotStrMarshalerFactory
|
18
24
|
from .composite.special import SequenceNotStrUnmarshalerFactory
|
25
|
+
from .factories.invalidate import InvalidatableMarshalerFactory
|
26
|
+
from .factories.invalidate import InvalidatableUnmarshalerFactory
|
27
|
+
from .factories.moduleimport.factories import ModuleImportingMarshalerFactory
|
28
|
+
from .factories.moduleimport.factories import ModuleImportingUnmarshalerFactory
|
19
29
|
from .factories.multi import MultiMarshalerFactory
|
20
30
|
from .factories.multi import MultiUnmarshalerFactory
|
21
31
|
from .factories.recursive import RecursiveMarshalerFactory
|
@@ -45,24 +55,53 @@ from .trivial.any import ANY_UNMARSHALER_FACTORY
|
|
45
55
|
##
|
46
56
|
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
class StandardFactories(ta.NamedTuple):
|
59
|
+
marshaler_factories: ta.Sequence[MarshalerFactory]
|
60
|
+
unmarshaler_factories: ta.Sequence[UnmarshalerFactory]
|
61
|
+
|
62
|
+
|
63
|
+
DEFAULT_STANDARD_FACTORIES = StandardFactories(
|
64
|
+
(
|
65
|
+
PRIMITIVE_MARSHALER_FACTORY,
|
66
|
+
NewtypeMarshalerFactory(),
|
67
|
+
OptionalMarshalerFactory(),
|
68
|
+
PrimitiveUnionMarshalerFactory(),
|
69
|
+
DataclassMarshalerFactory(),
|
70
|
+
NamedtupleMarshalerFactory(),
|
71
|
+
EnumMarshalerFactory(),
|
72
|
+
LiteralMarshalerFactory(),
|
73
|
+
NUMBERS_MARSHALER_FACTORY,
|
74
|
+
UUID_MARSHALER_FACTORY,
|
75
|
+
DATETIME_MARSHALER_FACTORY,
|
76
|
+
MaybeMarshalerFactory(),
|
77
|
+
MappingMarshalerFactory(),
|
78
|
+
SequenceNotStrMarshalerFactory(),
|
79
|
+
IterableMarshalerFactory(),
|
80
|
+
ANY_MARSHALER_FACTORY,
|
81
|
+
),
|
82
|
+
|
83
|
+
(
|
84
|
+
PRIMITIVE_UNMARSHALER_FACTORY,
|
85
|
+
NewtypeUnmarshalerFactory(),
|
86
|
+
OptionalUnmarshalerFactory(),
|
87
|
+
PrimitiveUnionUnmarshalerFactory(),
|
88
|
+
DataclassUnmarshalerFactory(),
|
89
|
+
NamedtupleUnmarshalerFactory(),
|
90
|
+
EnumUnmarshalerFactory(),
|
91
|
+
LiteralUnmarshalerFactory(),
|
92
|
+
NUMBERS_UNMARSHALER_FACTORY,
|
93
|
+
UUID_UNMARSHALER_FACTORY,
|
94
|
+
DATETIME_UNMARSHALER_FACTORY,
|
95
|
+
MaybeUnmarshalerFactory(),
|
96
|
+
MappingUnmarshalerFactory(),
|
97
|
+
SequenceNotStrUnmarshalerFactory(),
|
98
|
+
IterableUnmarshalerFactory(),
|
99
|
+
ANY_UNMARSHALER_FACTORY,
|
100
|
+
),
|
101
|
+
)
|
102
|
+
|
103
|
+
|
104
|
+
##
|
66
105
|
|
67
106
|
|
68
107
|
def new_standard_marshaler_factory(
|
@@ -70,38 +109,32 @@ def new_standard_marshaler_factory(
|
|
70
109
|
first: ta.Iterable[MarshalerFactory] | None = None,
|
71
110
|
last: ta.Iterable[MarshalerFactory] | None = None,
|
72
111
|
) -> MarshalerFactory:
|
73
|
-
|
74
|
-
RecursiveMarshalerFactory(
|
75
|
-
MultiMarshalerFactory([
|
76
|
-
*(first if first is not None else []),
|
77
|
-
*STANDARD_MARSHALER_FACTORIES,
|
78
|
-
*(last if last is not None else []),
|
79
|
-
]),
|
80
|
-
),
|
81
|
-
)
|
112
|
+
gl: ta.Any = None
|
82
113
|
|
114
|
+
def fi_fn():
|
115
|
+
nonlocal gl
|
116
|
+
gl = DEFAULT_STANDARD_FACTORIES
|
83
117
|
|
84
|
-
|
118
|
+
fi: MarshalerFactory = MultiMarshalerFactory([
|
119
|
+
*(first if first is not None else []),
|
120
|
+
*gl.marshaler_factories,
|
121
|
+
*(last if last is not None else []),
|
122
|
+
])
|
123
|
+
|
124
|
+
fi = RecursiveMarshalerFactory(fi)
|
125
|
+
|
126
|
+
fi = TypeCacheMarshalerFactory(fi)
|
85
127
|
|
128
|
+
return fi
|
86
129
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
LiteralUnmarshalerFactory(),
|
96
|
-
NUMBERS_UNMARSHALER_FACTORY,
|
97
|
-
UUID_UNMARSHALER_FACTORY,
|
98
|
-
DATETIME_UNMARSHALER_FACTORY,
|
99
|
-
MaybeUnmarshalerFactory(),
|
100
|
-
MappingUnmarshalerFactory(),
|
101
|
-
SequenceNotStrUnmarshalerFactory(),
|
102
|
-
IterableUnmarshalerFactory(),
|
103
|
-
ANY_UNMARSHALER_FACTORY,
|
104
|
-
]
|
130
|
+
fo: MarshalerFactory = (iv := InvalidatableMarshalerFactory(
|
131
|
+
fi_fn,
|
132
|
+
lambda: DEFAULT_STANDARD_FACTORIES is not gl,
|
133
|
+
))
|
134
|
+
|
135
|
+
fo = ModuleImportingMarshalerFactory(fo, iv.invalidate)
|
136
|
+
|
137
|
+
return fo
|
105
138
|
|
106
139
|
|
107
140
|
def new_standard_unmarshaler_factory(
|
@@ -109,33 +142,67 @@ def new_standard_unmarshaler_factory(
|
|
109
142
|
first: ta.Iterable[UnmarshalerFactory] | None = None,
|
110
143
|
last: ta.Iterable[UnmarshalerFactory] | None = None,
|
111
144
|
) -> UnmarshalerFactory:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
145
|
+
gl: ta.Any = None
|
146
|
+
|
147
|
+
def fi_fn():
|
148
|
+
nonlocal gl
|
149
|
+
gl = DEFAULT_STANDARD_FACTORIES
|
150
|
+
|
151
|
+
fi: UnmarshalerFactory = MultiUnmarshalerFactory([
|
152
|
+
*(first if first is not None else []),
|
153
|
+
*gl.unmarshaler_factories,
|
154
|
+
*(last if last is not None else []),
|
155
|
+
])
|
156
|
+
|
157
|
+
fi = RecursiveUnmarshalerFactory(fi)
|
158
|
+
|
159
|
+
fi = TypeCacheUnmarshalerFactory(fi)
|
160
|
+
|
161
|
+
return fi
|
162
|
+
|
163
|
+
fo: UnmarshalerFactory = (iv := InvalidatableUnmarshalerFactory(
|
164
|
+
fi_fn,
|
165
|
+
lambda: DEFAULT_STANDARD_FACTORIES is not gl,
|
166
|
+
))
|
167
|
+
|
168
|
+
fo = ModuleImportingUnmarshalerFactory(fo, iv.invalidate)
|
169
|
+
|
170
|
+
return fo
|
121
171
|
|
122
172
|
|
123
173
|
##
|
124
174
|
|
125
175
|
|
176
|
+
_GLOBAL_LOCK = threading.RLock()
|
177
|
+
|
178
|
+
|
126
179
|
def install_standard_factories(
|
127
180
|
*factories: MarshalerFactory | UnmarshalerFactory,
|
128
181
|
) -> None:
|
129
|
-
|
130
|
-
|
182
|
+
with _GLOBAL_LOCK:
|
183
|
+
global DEFAULT_STANDARD_FACTORIES
|
184
|
+
|
185
|
+
m_lst: list[MarshalerFactory] = list(DEFAULT_STANDARD_FACTORIES.marshaler_factories)
|
186
|
+
u_lst: list[UnmarshalerFactory] = list(DEFAULT_STANDARD_FACTORIES.unmarshaler_factories)
|
187
|
+
|
188
|
+
for f in factories:
|
189
|
+
k = False
|
190
|
+
|
191
|
+
if isinstance(f, MarshalerFactory):
|
192
|
+
m_lst[0:0] = [f]
|
193
|
+
k = True
|
194
|
+
|
195
|
+
if isinstance(f, UnmarshalerFactory):
|
196
|
+
u_lst[0:0] = [f]
|
197
|
+
k = True
|
131
198
|
|
132
|
-
|
133
|
-
|
134
|
-
k = True
|
199
|
+
if not k:
|
200
|
+
raise TypeError(f)
|
135
201
|
|
136
|
-
|
137
|
-
|
138
|
-
|
202
|
+
new = StandardFactories(
|
203
|
+
tuple(m_lst),
|
204
|
+
tuple(u_lst),
|
205
|
+
)
|
139
206
|
|
140
|
-
if
|
141
|
-
|
207
|
+
if new != DEFAULT_STANDARD_FACTORIES:
|
208
|
+
DEFAULT_STANDARD_FACTORIES = new
|
omlish/reflect/__init__.py
CHANGED
@@ -1,50 +1,60 @@
|
|
1
|
-
from
|
2
|
-
get_annotations,
|
3
|
-
get_filtered_type_hints,
|
4
|
-
has_annotations,
|
5
|
-
)
|
1
|
+
from .. import lang as _lang
|
6
2
|
|
7
|
-
from .ops import ( # noqa
|
8
|
-
get_concrete_type,
|
9
|
-
get_underlying,
|
10
|
-
strip_annotations,
|
11
|
-
strip_objs,
|
12
|
-
to_annotation,
|
13
|
-
types_equivalent,
|
14
|
-
)
|
15
3
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
get_type_var_replacements,
|
23
|
-
replace_type_vars,
|
24
|
-
)
|
4
|
+
with _lang.auto_proxy_init(
|
5
|
+
globals(),
|
6
|
+
update_exports=True,
|
7
|
+
# eager=True,
|
8
|
+
):
|
9
|
+
##
|
25
10
|
|
26
|
-
from .
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
11
|
+
from .inspect import ( # noqa
|
12
|
+
get_annotations,
|
13
|
+
get_filtered_type_hints,
|
14
|
+
has_annotations,
|
15
|
+
)
|
16
|
+
|
17
|
+
from .ops import ( # noqa
|
18
|
+
get_concrete_type,
|
19
|
+
get_underlying,
|
20
|
+
strip_annotations,
|
21
|
+
strip_objs,
|
22
|
+
to_annotation,
|
23
|
+
types_equivalent,
|
24
|
+
)
|
25
|
+
|
26
|
+
from .subst import ( # noqa
|
27
|
+
ALIAS_UPDATING_GENERIC_SUBSTITUTION,
|
28
|
+
DEFAULT_GENERIC_SUBSTITUTION,
|
29
|
+
GenericSubstitution,
|
30
|
+
generic_mro,
|
31
|
+
get_generic_bases,
|
32
|
+
get_type_var_replacements,
|
33
|
+
replace_type_vars,
|
34
|
+
)
|
35
|
+
|
36
|
+
from .types import ( # noqa
|
37
|
+
ANY,
|
38
|
+
Annotated,
|
39
|
+
Any,
|
40
|
+
DEFAULT_REFLECTOR,
|
41
|
+
Generic,
|
42
|
+
GenericLike,
|
43
|
+
Literal,
|
44
|
+
NewType,
|
45
|
+
Protocol,
|
46
|
+
ReflectTypeError,
|
47
|
+
Reflector,
|
48
|
+
TYPES,
|
49
|
+
Type,
|
50
|
+
TypeInfo,
|
51
|
+
Union,
|
52
|
+
get_newtype_supertype,
|
53
|
+
get_orig_bases,
|
54
|
+
get_orig_class,
|
55
|
+
get_params,
|
56
|
+
get_type_var_bound,
|
57
|
+
is_type,
|
58
|
+
is_union_type,
|
59
|
+
type_,
|
60
|
+
)
|
omlish/reflect/types.py
CHANGED
@@ -18,6 +18,7 @@ TODO:
|
|
18
18
|
"""
|
19
19
|
import abc
|
20
20
|
import dataclasses as dc
|
21
|
+
import threading
|
21
22
|
import types
|
22
23
|
import typing as ta
|
23
24
|
|
@@ -56,21 +57,149 @@ class _Special:
|
|
56
57
|
origin: type
|
57
58
|
nparams: int
|
58
59
|
|
60
|
+
@classmethod
|
61
|
+
def from_alias(cls, sa: _SpecialGenericAlias) -> '_Special': # type: ignore
|
62
|
+
return cls(
|
63
|
+
sa._name, # type: ignore # noqa
|
64
|
+
sa,
|
65
|
+
sa.__origin__, # type: ignore
|
66
|
+
sa._nparams, # type: ignore # noqa
|
67
|
+
)
|
59
68
|
|
60
|
-
_KNOWN_SPECIALS = [
|
61
|
-
_Special(
|
62
|
-
v._name, # noqa
|
63
|
-
v,
|
64
|
-
v.__origin__,
|
65
|
-
v._nparams, # noqa
|
66
|
-
)
|
67
|
-
for v in ta.__dict__.values() # noqa
|
68
|
-
if isinstance(v, _SpecialGenericAlias)
|
69
|
-
]
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
@dc.dataclass(frozen=True)
|
71
|
+
class _LazySpecial:
|
72
|
+
name: str
|
73
|
+
|
74
|
+
|
75
|
+
class _KnownSpecials:
|
76
|
+
def __init__(
|
77
|
+
self,
|
78
|
+
specials: ta.Iterable[_Special] = (),
|
79
|
+
lazy_specials: ta.Iterable[_LazySpecial] = (),
|
80
|
+
) -> None:
|
81
|
+
super().__init__()
|
82
|
+
|
83
|
+
self._lock = threading.RLock()
|
84
|
+
|
85
|
+
self._lst: list[_Special] = []
|
86
|
+
self._by_name: dict[str, _Special] = {}
|
87
|
+
self._by_alias: dict[_SpecialGenericAlias, _Special] = {} # type: ignore
|
88
|
+
self._by_origin: dict[type, _Special] = {}
|
89
|
+
|
90
|
+
self._lazies_by_name: dict[str, _LazySpecial] = {}
|
91
|
+
|
92
|
+
for sp in specials:
|
93
|
+
self._add(sp)
|
94
|
+
for lz in lazy_specials:
|
95
|
+
self._add_lazy(lz)
|
96
|
+
|
97
|
+
#
|
98
|
+
|
99
|
+
def _add(self, sp: _Special) -> None:
|
100
|
+
uds: list[tuple[ta.Any, ta.MutableMapping]] = [
|
101
|
+
(sp.name, self._by_name),
|
102
|
+
(sp.alias, self._by_alias),
|
103
|
+
(sp.origin, self._by_origin),
|
104
|
+
]
|
105
|
+
for k, dct in uds:
|
106
|
+
if k in dct:
|
107
|
+
raise KeyError(k)
|
108
|
+
|
109
|
+
if sp.name in self._lazies_by_name:
|
110
|
+
raise KeyError(sp.name)
|
111
|
+
|
112
|
+
self._lst.append(sp)
|
113
|
+
for k, dct in uds:
|
114
|
+
dct[k] = sp
|
115
|
+
|
116
|
+
def add(self, *specials: _Special) -> ta.Self:
|
117
|
+
with self._lock:
|
118
|
+
for sp in specials:
|
119
|
+
self._add(sp)
|
120
|
+
return self
|
121
|
+
|
122
|
+
#
|
123
|
+
|
124
|
+
def _add_lazy(self, lz: _LazySpecial) -> None:
|
125
|
+
if lz.name in self._lazies_by_name:
|
126
|
+
raise KeyError(lz.name)
|
127
|
+
if lz.name in self._by_name:
|
128
|
+
raise KeyError(lz.name)
|
129
|
+
|
130
|
+
self._lazies_by_name[lz.name] = lz
|
131
|
+
|
132
|
+
def add_lazy(self, *lazy_specials: _LazySpecial) -> ta.Self:
|
133
|
+
with self._lock:
|
134
|
+
for lz in lazy_specials:
|
135
|
+
self._add_lazy(lz)
|
136
|
+
return self
|
137
|
+
|
138
|
+
#
|
139
|
+
|
140
|
+
def _get_lazy_by_name(self, name: str) -> _Special | None:
|
141
|
+
if name not in self._lazies_by_name:
|
142
|
+
return None
|
143
|
+
|
144
|
+
with self._lock:
|
145
|
+
if (x := self._by_name.get(name)) is not None:
|
146
|
+
return x
|
147
|
+
|
148
|
+
if (lz := self._lazies_by_name.get(name)) is None:
|
149
|
+
return None
|
150
|
+
|
151
|
+
sa = getattr(ta, lz.name)
|
152
|
+
if not isinstance(sa, _SpecialGenericAlias):
|
153
|
+
raise TypeError(sa)
|
154
|
+
|
155
|
+
sp = _Special.from_alias(sa)
|
156
|
+
del self._lazies_by_name[lz.name]
|
157
|
+
self._add(sp)
|
158
|
+
|
159
|
+
return sp
|
160
|
+
|
161
|
+
def get_by_name(self, name: str) -> _Special | None:
|
162
|
+
try:
|
163
|
+
return self._by_name.get(name)
|
164
|
+
except KeyError:
|
165
|
+
pass
|
166
|
+
return self._get_lazy_by_name(name)
|
167
|
+
|
168
|
+
def get_by_alias(self, alias: _SpecialGenericAlias) -> _Special | None: # type: ignore
|
169
|
+
try:
|
170
|
+
return self._by_alias[alias]
|
171
|
+
except KeyError:
|
172
|
+
pass
|
173
|
+
return self._get_lazy_by_name(alias._name) # type: ignore # noqa
|
174
|
+
|
175
|
+
def get_by_origin(self, origin: type) -> _Special | None:
|
176
|
+
return self._by_origin.get(origin)
|
177
|
+
|
178
|
+
|
179
|
+
_KNOWN_SPECIALS = _KnownSpecials(
|
180
|
+
[
|
181
|
+
_Special.from_alias(v)
|
182
|
+
for v in ta.__dict__.values() # noqa
|
183
|
+
if isinstance(v, _SpecialGenericAlias)
|
184
|
+
],
|
185
|
+
[
|
186
|
+
_LazySpecial(n)
|
187
|
+
for n in [
|
188
|
+
# https://github.com/python/cpython/commit/e8be0c9c5a7c2327b3dd64009f45ee0682322dcb
|
189
|
+
'Pattern',
|
190
|
+
'Match',
|
191
|
+
'ContextManager',
|
192
|
+
'AsyncContextManager',
|
193
|
+
# https://github.com/python/cpython/commit/305be5fb1a1ece7f9651ae98053dbe79bf439aa4
|
194
|
+
'ForwardRef',
|
195
|
+
]
|
196
|
+
if n not in ta.__dict__
|
197
|
+
],
|
198
|
+
)
|
199
|
+
|
200
|
+
|
201
|
+
##
|
202
|
+
|
74
203
|
|
75
204
|
_MAX_KNOWN_SPECIAL_TYPE_VARS = 16
|
76
205
|
|
@@ -99,7 +228,7 @@ def get_params(obj: ta.Any) -> tuple[ta.TypeVar, ...]:
|
|
99
228
|
if issubclass(obj, ta.Generic): # type: ignore
|
100
229
|
return obj.__dict__.get('__parameters__', ()) # noqa
|
101
230
|
|
102
|
-
if (ks :=
|
231
|
+
if (ks := _KNOWN_SPECIALS.get_by_origin(obj)) is not None:
|
103
232
|
if (np := ks.nparams) < 0:
|
104
233
|
raise TypeError(obj)
|
105
234
|
return _KNOWN_SPECIAL_TYPE_VARS[:np]
|
@@ -442,7 +571,7 @@ class Reflector:
|
|
442
571
|
# Special Generic
|
443
572
|
|
444
573
|
if isinstance(obj, _SpecialGenericAlias):
|
445
|
-
if (ks :=
|
574
|
+
if (ks := _KNOWN_SPECIALS.get_by_alias(obj)) is not None:
|
446
575
|
if check_only:
|
447
576
|
return None
|
448
577
|
|
omlish/secrets/all.py
CHANGED
omlish/secrets/secrets.py
CHANGED
@@ -20,6 +20,10 @@ import typing as ta
|
|
20
20
|
|
21
21
|
from .. import dataclasses as dc
|
22
22
|
from .. import lang
|
23
|
+
from .. import marshal as msh
|
24
|
+
|
25
|
+
|
26
|
+
msh.register_global_module_import('.marshal', __package__)
|
23
27
|
|
24
28
|
|
25
29
|
log = logging.getLogger(__name__)
|
@@ -341,9 +345,3 @@ class EnvVarSecrets(Secrets):
|
|
341
345
|
return dct.pop(ekey)
|
342
346
|
else:
|
343
347
|
return dct[ekey]
|
344
|
-
|
345
|
-
|
346
|
-
##
|
347
|
-
|
348
|
-
|
349
|
-
lang.register_conditional_import('..marshal', '.marshal', __package__)
|
omlish/specs/jsonrpc/__init__.py
CHANGED
omlish/specs/openapi/__init__.py
CHANGED
omlish/sql/queries/__init__.py
CHANGED
@@ -112,8 +112,10 @@ Q = StdBuilder()
|
|
112
112
|
##
|
113
113
|
|
114
114
|
|
115
|
-
from ... import
|
115
|
+
from ... import marshal as _msh # noqa
|
116
|
+
|
117
|
+
_msh.register_global_module_import('._marshal', __package__)
|
116
118
|
|
117
|
-
|
119
|
+
from ... import lang as _lang # noqa
|
118
120
|
|
119
121
|
_lang.trigger_conditional_imports(__package__)
|
omlish/sql/tabledefs/__init__.py
CHANGED
omlish/typedvalues/__init__.py
CHANGED