omlish 0.0.0.dev121__py3-none-any.whl → 0.0.0.dev122__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- omlish/__about__.py +2 -2
- omlish/lite/inject.py +6 -1
- omlish/lite/reflect.py +9 -0
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/RECORD +9 -9
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev121.dist-info → omlish-0.0.0.dev122.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/lite/inject.py
CHANGED
@@ -11,6 +11,7 @@ from .check import check_isinstance
|
|
11
11
|
from .check import check_not_isinstance
|
12
12
|
from .maybes import Maybe
|
13
13
|
from .reflect import get_optional_alias_arg
|
14
|
+
from .reflect import is_new_type
|
14
15
|
from .reflect import is_optional_alias
|
15
16
|
|
16
17
|
|
@@ -110,7 +111,7 @@ def as_injector_key(o: ta.Any) -> InjectorKey:
|
|
110
111
|
raise TypeError(o)
|
111
112
|
if isinstance(o, InjectorKey):
|
112
113
|
return o
|
113
|
-
if isinstance(o,
|
114
|
+
if isinstance(o, type) or is_new_type(o):
|
114
115
|
return InjectorKey(o)
|
115
116
|
raise TypeError(o)
|
116
117
|
|
@@ -226,6 +227,7 @@ class _InjectorBindings(InjectorBindings):
|
|
226
227
|
def as_injector_bindings(*args: InjectorBindingOrBindings) -> InjectorBindings:
|
227
228
|
bs: ta.List[InjectorBinding] = []
|
228
229
|
ps: ta.List[InjectorBindings] = []
|
230
|
+
|
229
231
|
for a in args:
|
230
232
|
if isinstance(a, InjectorBindings):
|
231
233
|
ps.append(a)
|
@@ -233,6 +235,7 @@ def as_injector_bindings(*args: InjectorBindingOrBindings) -> InjectorBindings:
|
|
233
235
|
bs.append(a)
|
234
236
|
else:
|
235
237
|
raise TypeError(a)
|
238
|
+
|
236
239
|
return _InjectorBindings(
|
237
240
|
bs or None,
|
238
241
|
ps or None,
|
@@ -254,10 +257,12 @@ class OverridesInjectorBindings(InjectorBindings):
|
|
254
257
|
|
255
258
|
def injector_override(p: InjectorBindings, *args: InjectorBindingOrBindings) -> InjectorBindings:
|
256
259
|
m: ta.Dict[InjectorKey, InjectorBinding] = {}
|
260
|
+
|
257
261
|
for b in as_injector_bindings(*args).bindings():
|
258
262
|
if b.key in m:
|
259
263
|
raise DuplicateInjectorKeyError(b.key)
|
260
264
|
m[b.key] = b
|
265
|
+
|
261
266
|
return OverridesInjectorBindings(p, m)
|
262
267
|
|
263
268
|
|
omlish/lite/reflect.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# ruff: noqa: UP006
|
2
2
|
import functools
|
3
|
+
import types
|
3
4
|
import typing as ta
|
4
5
|
|
5
6
|
|
@@ -37,6 +38,14 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
|
|
37
38
|
return it
|
38
39
|
|
39
40
|
|
41
|
+
def is_new_type(spec: ta.Any) -> bool:
|
42
|
+
if isinstance(ta.NewType, type):
|
43
|
+
return isinstance(spec, ta.NewType)
|
44
|
+
else:
|
45
|
+
# Before https://github.com/python/cpython/commit/c2f33dfc83ab270412bf243fb21f724037effa1a
|
46
|
+
return isinstance(spec, types.FunctionType) and spec.__code__ is ta.NewType.__code__.co_consts[1] # type: ignore # noqa
|
47
|
+
|
48
|
+
|
40
49
|
def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
|
41
50
|
seen = set()
|
42
51
|
todo = list(reversed(cls.__subclasses__()))
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=CxGnj-UiRPlZgmgWoovDWrOnqpSEmBy_kqA7cdfSA3w,1431
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=W3oofnGfBAEjbOcl3if2RLeaUM_umelQSS1abx6YVZ0,3352
|
3
3
|
omlish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
omlish/argparse.py,sha256=cqKGAqcxuxv_s62z0gq29L9KAvg_3-_rFvXKjVpRJjo,8126
|
5
5
|
omlish/c3.py,sha256=4vogWgwPb8TbNS2KkZxpoWbwjj7MuHG2lQG-hdtkvjI,8062
|
@@ -302,7 +302,7 @@ omlish/lite/cached.py,sha256=Fs-ljXVJmHBjAaHc-JuJXMEV4MNSX5c_KHZIM3AEaIw,694
|
|
302
302
|
omlish/lite/check.py,sha256=ouJme9tkzWXKymm_xZDK4mngdYSkxDrok6CSegvf-1w,1015
|
303
303
|
omlish/lite/contextmanagers.py,sha256=_jfNdpYvxkbKwyjQLbK-o69W89GoEuUfl_NrCosE9lU,1308
|
304
304
|
omlish/lite/docker.py,sha256=3IVZZtIm7-UdB2SwArmN_MosTva1_KifyYp3YWjODbE,337
|
305
|
-
omlish/lite/inject.py,sha256=
|
305
|
+
omlish/lite/inject.py,sha256=wIFQouJVxjevw_Ik9t0YyKIpi2j1KGDWTGUdaDP2xN4,15101
|
306
306
|
omlish/lite/io.py,sha256=lcpI1cS_Kn90tvYMg8ZWkSlYloS4RFqXCk-rKyclhdg,3148
|
307
307
|
omlish/lite/journald.py,sha256=3nfahFbTrdrfp9txhtto6JYAyrus2kcAFtviqdm3qAo,3949
|
308
308
|
omlish/lite/json.py,sha256=7-02Ny4fq-6YAu5ynvqoijhuYXWpLmfCI19GUeZnb1c,740
|
@@ -310,7 +310,7 @@ omlish/lite/logs.py,sha256=tw7mbQslkyo9LopfgQnj0tYiqJ9TDNiw7D07aF7Dm2g,6176
|
|
310
310
|
omlish/lite/marshal.py,sha256=SyYMsJ-TaGO9FX7LykBB0WtqsqetX9eLBotPiz3M_xg,9478
|
311
311
|
omlish/lite/maybes.py,sha256=7OlHJ8Q2r4wQ-aRbZSlJY7x0e8gDvufFdlohGEIJ3P4,833
|
312
312
|
omlish/lite/pidfile.py,sha256=PRSDOAXmNkNwxh-Vwif0Nrs8RAmWroiNhLKIbdjwzBc,1723
|
313
|
-
omlish/lite/reflect.py,sha256=
|
313
|
+
omlish/lite/reflect.py,sha256=ad_ya_zZJOQB8HoNjs9yc66R54zgflwJVPJqiBXMzqA,1681
|
314
314
|
omlish/lite/runtime.py,sha256=VUhmNQvwf8QzkWSKj4Q0ReieJA_PzHaJNRBivfTseow,452
|
315
315
|
omlish/lite/secrets.py,sha256=3Mz3V2jf__XU9qNHcH56sBSw95L3U2UPL24bjvobG0c,816
|
316
316
|
omlish/lite/strings.py,sha256=QURcE4-1pKVW8eT_5VCJpXaHDWR2dW2pYOChTJnZDiQ,1504
|
@@ -473,9 +473,9 @@ omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,329
|
|
473
473
|
omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
|
474
474
|
omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
|
475
475
|
omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
|
476
|
-
omlish-0.0.0.
|
477
|
-
omlish-0.0.0.
|
478
|
-
omlish-0.0.0.
|
479
|
-
omlish-0.0.0.
|
480
|
-
omlish-0.0.0.
|
481
|
-
omlish-0.0.0.
|
476
|
+
omlish-0.0.0.dev122.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
477
|
+
omlish-0.0.0.dev122.dist-info/METADATA,sha256=_jwjqVyP1FYdDhGjA0juayR13H-KGTmaJ3wqd4gbQ6I,4000
|
478
|
+
omlish-0.0.0.dev122.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
479
|
+
omlish-0.0.0.dev122.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
480
|
+
omlish-0.0.0.dev122.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
481
|
+
omlish-0.0.0.dev122.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|