omlish 0.0.0.dev329__py3-none-any.whl → 0.0.0.dev330__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/lang/cached/function.py +13 -3
- omlish/marshal/__init__.py +1 -0
- omlish/marshal/polymorphism/metadata.py +17 -14
- omlish/reflect/ops.py +24 -10
- omlish/reflect/subst.py +2 -2
- omlish/typedvalues/generic.py +1 -5
- omlish/typedvalues/marshal.py +11 -5
- omlish/typedvalues/reflect.py +18 -3
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/RECORD +15 -15
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev329.dist-info → omlish-0.0.0.dev330.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/lang/cached/function.py
CHANGED
@@ -331,13 +331,23 @@ class _DescriptorCachedFunction(_CachedFunction[T]):
|
|
331
331
|
raise RuntimeError
|
332
332
|
obj = type(instance)
|
333
333
|
|
334
|
-
desc: _DescriptorCachedFunction
|
334
|
+
desc: _DescriptorCachedFunction
|
335
|
+
for bc in obj.__mro__[:-1]:
|
336
|
+
try:
|
337
|
+
desc = bc.__dict__[name]
|
338
|
+
except KeyError:
|
339
|
+
continue
|
340
|
+
break
|
341
|
+
else:
|
342
|
+
raise AttributeError(name)
|
343
|
+
|
335
344
|
if not isinstance(desc, cls):
|
336
345
|
raise TypeError(desc)
|
337
|
-
|
346
|
+
|
347
|
+
if (desc._instance is not None or desc._owner is not None): # noqa
|
338
348
|
raise RuntimeError
|
339
349
|
|
340
|
-
return desc._bind(
|
350
|
+
return desc._bind( # noqa
|
341
351
|
instance,
|
342
352
|
owner,
|
343
353
|
values=values,
|
omlish/marshal/__init__.py
CHANGED
@@ -105,25 +105,14 @@ class Polymorphism:
|
|
105
105
|
return self._impls
|
106
106
|
|
107
107
|
|
108
|
-
def
|
108
|
+
def polymorphism_from_impls(
|
109
109
|
ty: type,
|
110
|
+
impls: ta.Iterable[type],
|
110
111
|
*,
|
111
112
|
naming: Naming | None = None,
|
112
113
|
strip_suffix: bool | ta.Literal['auto'] = False,
|
113
114
|
) -> Polymorphism:
|
114
|
-
|
115
|
-
todo: list[type] = [ty]
|
116
|
-
impls: set[type] = set()
|
117
|
-
while todo:
|
118
|
-
cur = todo.pop()
|
119
|
-
seen.add(cur)
|
120
|
-
|
121
|
-
todo.extend(nxt for nxt in cur.__subclasses__() if nxt not in seen)
|
122
|
-
|
123
|
-
if lang.is_abstract_class(cur):
|
124
|
-
continue
|
125
|
-
|
126
|
-
impls.add(cur)
|
115
|
+
impls = set(impls)
|
127
116
|
|
128
117
|
if strip_suffix == 'auto':
|
129
118
|
strip_suffix = all(c.__name__.endswith(ty.__name__) for c in impls)
|
@@ -144,3 +133,17 @@ def polymorphism_from_subclasses(
|
|
144
133
|
)
|
145
134
|
|
146
135
|
return Polymorphism(ty, dct.values())
|
136
|
+
|
137
|
+
|
138
|
+
def polymorphism_from_subclasses(
|
139
|
+
ty: type,
|
140
|
+
*,
|
141
|
+
naming: Naming | None = None,
|
142
|
+
strip_suffix: bool | ta.Literal['auto'] = False,
|
143
|
+
) -> Polymorphism:
|
144
|
+
return polymorphism_from_impls(
|
145
|
+
ty,
|
146
|
+
lang.deep_subclasses(ty, concrete_only=True),
|
147
|
+
naming=naming,
|
148
|
+
strip_suffix=strip_suffix,
|
149
|
+
)
|
omlish/reflect/ops.py
CHANGED
@@ -6,6 +6,7 @@ from .types import Generic
|
|
6
6
|
from .types import NewType
|
7
7
|
from .types import Type
|
8
8
|
from .types import Union
|
9
|
+
from .types import get_type_var_bound
|
9
10
|
from .types import type_
|
10
11
|
|
11
12
|
|
@@ -52,20 +53,33 @@ def get_underlying(nt: NewType) -> Type:
|
|
52
53
|
return type_(nt.obj.__supertype__) # noqa
|
53
54
|
|
54
55
|
|
55
|
-
def get_concrete_type(
|
56
|
-
|
57
|
-
|
56
|
+
def get_concrete_type(
|
57
|
+
ty: Type,
|
58
|
+
*,
|
59
|
+
use_type_var_bound: bool = False,
|
60
|
+
) -> type | None:
|
61
|
+
def rec(cur: Type) -> type | None:
|
62
|
+
if isinstance(cur, type):
|
63
|
+
return cur
|
58
64
|
|
59
|
-
|
60
|
-
|
65
|
+
if isinstance(cur, Generic):
|
66
|
+
return cur.cls
|
61
67
|
|
62
|
-
|
63
|
-
|
68
|
+
if isinstance(cur, NewType):
|
69
|
+
return rec(get_underlying(cur))
|
64
70
|
|
65
|
-
|
66
|
-
|
71
|
+
if isinstance(cur, ta.TypeVar):
|
72
|
+
if use_type_var_bound is not None and (tvb := get_type_var_bound(cur)) is not None:
|
73
|
+
return rec(type_(tvb))
|
67
74
|
|
68
|
-
|
75
|
+
return None
|
76
|
+
|
77
|
+
if isinstance(cur, (Union, Any)):
|
78
|
+
return None
|
79
|
+
|
80
|
+
raise TypeError(cur)
|
81
|
+
|
82
|
+
return rec(ty)
|
69
83
|
|
70
84
|
|
71
85
|
def to_annotation(ty: Type) -> ta.Any:
|
omlish/reflect/subst.py
CHANGED
@@ -85,12 +85,12 @@ class GenericSubstitution:
|
|
85
85
|
if (cty := get_concrete_type(ty)) is not None:
|
86
86
|
rpl = get_type_var_replacements(ty)
|
87
87
|
ret: list[Type] = []
|
88
|
-
|
88
|
+
obs = types.get_original_bases(cty)
|
89
|
+
for b in obs:
|
89
90
|
bty = type_(b)
|
90
91
|
if isinstance(bty, Generic) and isinstance(b, type):
|
91
92
|
# FIXME: throws away relative types, but can't use original vars as they're class-contextual
|
92
93
|
bty = type_(b[*((ta.Any,) * len(bty.params))]) # type: ignore
|
93
|
-
# rpl2 = {p: rpl[a] for p, a in zip(bty.params, bty.args)}
|
94
94
|
rty = replace_type_vars(bty, rpl, update_aliases=self._update_aliases)
|
95
95
|
ret.append(rty)
|
96
96
|
return tuple(ret)
|
omlish/typedvalues/generic.py
CHANGED
@@ -22,10 +22,6 @@ class TypedValueGeneric(lang.Abstract, ta.Generic[TypedValueT]):
|
|
22
22
|
return
|
23
23
|
|
24
24
|
g_mro = rfl.ALIAS_UPDATING_GENERIC_SUBSTITUTION.generic_mro(cls)
|
25
|
-
g_tvg = check.single(
|
26
|
-
gb
|
27
|
-
for gb in g_mro
|
28
|
-
if isinstance(gb, rfl.Generic) and gb.cls is TypedValueGeneric
|
29
|
-
)
|
25
|
+
g_tvg = check.single(gb for gb in g_mro if isinstance(gb, rfl.Generic) and gb.cls is TypedValueGeneric)
|
30
26
|
tvt = check.single(g_tvg.args)
|
31
27
|
cls._typed_value_type = tvt
|
omlish/typedvalues/marshal.py
CHANGED
@@ -81,12 +81,18 @@ def _build_typed_values_impls(rty: rfl.Type) -> msh.Impls:
|
|
81
81
|
gty = check.isinstance(rty, rfl.Generic)
|
82
82
|
check.is_(gty.cls, TypedValues)
|
83
83
|
|
84
|
-
tv_cls_set = reflect_typed_values_impls(
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
tv_impls.extend(_build_typed_value_poly(tv_cls).impls)
|
84
|
+
tv_cls_set = reflect_typed_values_impls(
|
85
|
+
check.single(gty.args),
|
86
|
+
find_abstract_subclasses=True,
|
87
|
+
)
|
89
88
|
|
89
|
+
tv_impls: list[msh.Impl] = [
|
90
|
+
msh.Impl(
|
91
|
+
tv_cls,
|
92
|
+
msh.translate_name(tv_cls.__name__, msh.Naming.SNAKE),
|
93
|
+
)
|
94
|
+
for tv_cls in tv_cls_set
|
95
|
+
]
|
90
96
|
return msh.Impls(tv_impls)
|
91
97
|
|
92
98
|
|
omlish/typedvalues/reflect.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import typing as ta
|
2
2
|
|
3
3
|
from .. import check
|
4
|
+
from .. import lang
|
4
5
|
from .. import reflect as rfl
|
5
6
|
from .values import TypedValue
|
6
7
|
|
@@ -8,10 +9,13 @@ from .values import TypedValue
|
|
8
9
|
##
|
9
10
|
|
10
11
|
|
11
|
-
def reflect_typed_values_impls(
|
12
|
+
def reflect_typed_values_impls(
|
13
|
+
*rtys: rfl.Type,
|
14
|
+
find_abstract_subclasses: bool = False,
|
15
|
+
) -> set[type[TypedValue]]:
|
12
16
|
tv_cls_set: set[type[TypedValue]] = set()
|
13
17
|
|
14
|
-
todo =
|
18
|
+
todo = list(rtys)
|
15
19
|
seen = set()
|
16
20
|
while todo:
|
17
21
|
cur = todo.pop()
|
@@ -21,9 +25,20 @@ def reflect_typed_values_impls(rty: rfl.Type) -> set[type[TypedValue]]:
|
|
21
25
|
|
22
26
|
if isinstance(cur, rfl.Union):
|
23
27
|
todo.extend(cur.args)
|
28
|
+
|
24
29
|
elif isinstance(cur, ta.TypeVar):
|
25
30
|
todo.append(rfl.type_(rfl.get_type_var_bound(cur)))
|
31
|
+
|
32
|
+
elif isinstance(cur, type):
|
33
|
+
cur = check.issubclass(check.isinstance(cur, type), TypedValue)
|
34
|
+
|
35
|
+
if find_abstract_subclasses and lang.is_abstract_class(cur):
|
36
|
+
todo.extend(lang.deep_subclasses(cur, concrete_only=True))
|
37
|
+
|
38
|
+
else:
|
39
|
+
tv_cls_set.add(cur)
|
40
|
+
|
26
41
|
else:
|
27
|
-
|
42
|
+
raise TypeError(cur)
|
28
43
|
|
29
44
|
return tv_cls_set
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=orgsRvtpHu8tdhaCvlP9v3P495OJopYYiHKjK68WtWg,8587
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=LOOmES3-MH0InTp6s_UkS6QtPhcOFz7C1XEnVq7wTmM,3478
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
4
4
|
omlish/c3.py,sha256=rer-TPOFDU6fYq_AWio_AmA-ckZ8JDY5shIzQ_yXfzA,8414
|
5
5
|
omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
|
@@ -429,7 +429,7 @@ omlish/lang/strings.py,sha256=kJmRFd1D36xXcjd9MdB12BCwF_-MVhNr-TpWj7hMi_4,4252
|
|
429
429
|
omlish/lang/sys.py,sha256=b4qOPiJZQru_mbb04FNfOjYWUxlV2becZOoc-yya_rQ,411
|
430
430
|
omlish/lang/typing.py,sha256=eWI3RKhVi-_SV2rN4SGq8IbFo5XbGapbiWeduF97uG8,3846
|
431
431
|
omlish/lang/cached/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
432
|
-
omlish/lang/cached/function.py,sha256
|
432
|
+
omlish/lang/cached/function.py,sha256=su9QxYECK9NK-UfMFKbgx4lqH2WoGBiYshnEfaGvfhw,11522
|
433
433
|
omlish/lang/cached/property.py,sha256=WHYyg4-6EA86TcNMfbXTjVhjEZPc0kngt9hfY3WN5w8,2768
|
434
434
|
omlish/lang/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
435
435
|
omlish/lang/classes/abstract.py,sha256=A-Jg5X8o_WvFryN0Cm2TpVkrZoTT1SYKQnv_pXjZk7o,3808
|
@@ -488,7 +488,7 @@ omlish/manifests/base.py,sha256=D1WvJYcBR_njkc0gpALpFCWh1h3agb9qgqphnbbPlm4,935
|
|
488
488
|
omlish/manifests/load.py,sha256=9mdsS3egmSX9pymO-m-y2Fhs4p6ruOdbsYaKT1-1Hwg,6655
|
489
489
|
omlish/manifests/static.py,sha256=7YwOVh_Ek9_aTrWsWNO8kWS10_j4K7yv3TpXZSHsvDY,501
|
490
490
|
omlish/manifests/types.py,sha256=IOt9dOe0r8okCHSL82ryi3sn4VZ6AT80g_QQR6oZtCE,306
|
491
|
-
omlish/marshal/__init__.py,sha256=
|
491
|
+
omlish/marshal/__init__.py,sha256=7jIXe9wQv-if1iRUuU6a4MdHScTLFFL8X2JwHaNTAxI,3395
|
492
492
|
omlish/marshal/base.py,sha256=Q0ZRsz5z0NTI6PeWPc9mdMstJryDDbeIAdpKH9-SDps,11427
|
493
493
|
omlish/marshal/errors.py,sha256=g5XJyTHd__8lfwQ4KwgK-E5WR6MoNTMrqKP2U_QRQQQ,307
|
494
494
|
omlish/marshal/factories.py,sha256=Q926jSVjaQLEmStnHLhm_c_vqEysN1LnDCwAsFLIzXw,2970
|
@@ -515,7 +515,7 @@ omlish/marshal/objects/namedtuples.py,sha256=8de8L7rwmvr_LLBHHfOl2wHObxc_1yZ8fC_
|
|
515
515
|
omlish/marshal/objects/unmarshal.py,sha256=IXIl_iokvVCSWYhkRORrWP_sE1DVklnrUErGWg_3MDc,3632
|
516
516
|
omlish/marshal/polymorphism/__init__.py,sha256=e2UTrSL0qp7w_1vkdxDWd7sXlWhep2KPV49-BB64ma8,130
|
517
517
|
omlish/marshal/polymorphism/marshal.py,sha256=wVaUxiHMJwyEWfQIE3cuEcJFSMVNJhpdJoa1yRgBPUE,2260
|
518
|
-
omlish/marshal/polymorphism/metadata.py,sha256=
|
518
|
+
omlish/marshal/polymorphism/metadata.py,sha256=Tvrjvi1kVhBbuljcQI60BXOIPEh-0_MGHXZDP-YKg1M,3335
|
519
519
|
omlish/marshal/polymorphism/unions.py,sha256=NDXh2aVCLUFfi10qvIZR39prtHwjndQiVl13XcIKV3k,4386
|
520
520
|
omlish/marshal/polymorphism/unmarshal.py,sha256=5jJnDarY85PuGTeL_9bwoeHjNIZnfVN3zr5rVhmNoQc,2451
|
521
521
|
omlish/marshal/singular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -565,8 +565,8 @@ omlish/os/pidfiles/pidfile.py,sha256=9tI5IMVwfPfnni0XMn4x5ptNQgm36n8tLeUNPf50UqU
|
|
565
565
|
omlish/os/pidfiles/pinning.py,sha256=aQgCmvcAqN0lvI70GcSB2TKVX1G4vwbyN_AOHF3-eKE,6630
|
566
566
|
omlish/reflect/__init__.py,sha256=64eHbD6zL6Fhp7FfXb8n9ZHywlODjBN3rm1LMvZ081A,822
|
567
567
|
omlish/reflect/inspect.py,sha256=WCo2YpBYauKw6k758FLlZ_H4Q05rgVPs96fEv9w6zHQ,1538
|
568
|
-
omlish/reflect/ops.py,sha256=
|
569
|
-
omlish/reflect/subst.py,sha256=
|
568
|
+
omlish/reflect/ops.py,sha256=9F369zrp6dNJUiGLLrYhb2O-Zss0BhTcpo3dzdLCq-I,2424
|
569
|
+
omlish/reflect/subst.py,sha256=jpBgYR1_JyH9fz5b-gmOg7OhFKk7jIxEh7hwtKYKC9Q,3691
|
570
570
|
omlish/reflect/types.py,sha256=Cn9FYGoiCNt0FS0YLiTTAR12WKcesWMapCrVYcb8IDo,9225
|
571
571
|
omlish/secrets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
572
572
|
omlish/secrets/all.py,sha256=gv_d9SfyMxso30HsrSz9XmIrSZOdl3rLA5MSH0ZXfgM,486
|
@@ -852,14 +852,14 @@ omlish/typedvalues/__init__.py,sha256=nzpnoRW_wScMPit5Xz37ky3nKBdzzkgtnQA4SfVHN8
|
|
852
852
|
omlish/typedvalues/accessor.py,sha256=_NEGBmQ84-h_rDfYeoq7DA20fhj3dogQuvzxXKhjx54,3121
|
853
853
|
omlish/typedvalues/collection.py,sha256=a6Je_kmz2FlAV2dI92S7c_paXge0QExMynV-fD9oPrs,5823
|
854
854
|
omlish/typedvalues/consumer.py,sha256=peDQAgriSyBx_Hc8QHAhEgYy0oSS52qQ_7Tqdssl2AE,4375
|
855
|
-
omlish/typedvalues/generic.py,sha256=
|
855
|
+
omlish/typedvalues/generic.py,sha256=ft-x4X3k1oFirtYnDfsvrI3ZQikWM8lGLrvrOEbcGq0,742
|
856
856
|
omlish/typedvalues/holder.py,sha256=vu-umn-h1nvUqmtV5T9ZfQ_OoOYsERu8PhI2N48Ryns,1133
|
857
|
-
omlish/typedvalues/marshal.py,sha256=
|
858
|
-
omlish/typedvalues/reflect.py,sha256=
|
857
|
+
omlish/typedvalues/marshal.py,sha256=IaZn1r4le5sq8_HcEJf_WEzS-NmeOaNQggmZxfEoIio,4332
|
858
|
+
omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
|
859
859
|
omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
|
860
|
-
omlish-0.0.0.
|
861
|
-
omlish-0.0.0.
|
862
|
-
omlish-0.0.0.
|
863
|
-
omlish-0.0.0.
|
864
|
-
omlish-0.0.0.
|
865
|
-
omlish-0.0.0.
|
860
|
+
omlish-0.0.0.dev330.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
861
|
+
omlish-0.0.0.dev330.dist-info/METADATA,sha256=Feb56v6VrdVgD2PiRe6OpzAxwDWhUF1BhmcheWSajVI,4416
|
862
|
+
omlish-0.0.0.dev330.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
863
|
+
omlish-0.0.0.dev330.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
864
|
+
omlish-0.0.0.dev330.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
865
|
+
omlish-0.0.0.dev330.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|