omlish 0.0.0.dev121__py3-none-any.whl → 0.0.0.dev123__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev121'
2
- __revision__ = '8d604587a14f8faa089e1a5d3ff68756b93b0c1f'
1
+ __version__ = '0.0.0.dev123'
2
+ __revision__ = '09fa6f9aa73934c146949b217e1a50a12e238dda'
3
3
 
4
4
 
5
5
  #
omlish/lite/check.py CHANGED
@@ -5,7 +5,7 @@ import typing as ta
5
5
  T = ta.TypeVar('T')
6
6
 
7
7
 
8
- def check_isinstance(v: T, spec: ta.Union[ta.Type[T], tuple]) -> T:
8
+ def check_isinstance(v: ta.Any, spec: ta.Union[ta.Type[T], tuple]) -> T:
9
9
  if not isinstance(v, spec):
10
10
  raise TypeError(v)
11
11
  return v
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, (type, ta.NewType)):
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omlish
3
- Version: 0.0.0.dev121
3
+ Version: 0.0.0.dev123
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=CxGnj-UiRPlZgmgWoovDWrOnqpSEmBy_kqA7cdfSA3w,1431
2
- omlish/__about__.py,sha256=aTRzdXeouYEQLsJZyhmeZxxg3aaQgoLMDv_T3jZ_HZE,3352
2
+ omlish/__about__.py,sha256=EwBUPQ7vULV4lYbnhDO--dJgPaiH6NhwtKN_SIhWuDg,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
@@ -299,10 +299,10 @@ omlish/lifecycles/states.py,sha256=zqMOU2ZU-MDNnWuwauM3_anIAiXM8LoBDElDEraptFg,1
299
299
  omlish/lifecycles/transitions.py,sha256=qQtFby-h4VzbvgaUqT2NnbNumlcOx9FVVADP9t83xj4,1939
300
300
  omlish/lite/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
301
301
  omlish/lite/cached.py,sha256=Fs-ljXVJmHBjAaHc-JuJXMEV4MNSX5c_KHZIM3AEaIw,694
302
- omlish/lite/check.py,sha256=ouJme9tkzWXKymm_xZDK4mngdYSkxDrok6CSegvf-1w,1015
302
+ omlish/lite/check.py,sha256=HGxpv6x9kgHoaM0itjId9uCo5Lsfu2LEf1VyMJO98jc,1020
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=O3k8EYRKRKTkqoamM7awbcBvnYwy_fKIUPVf4FcObyg,15060
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=9QYJwdINraq1JNMEgvoqeSlVvRRgOXpxAkpgX8EgRXc,1307
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.dev121.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
477
- omlish-0.0.0.dev121.dist-info/METADATA,sha256=a5C2OhlCjHtn2VNKTUvzGAslZqvU4XAYaOvBfNd1884,4000
478
- omlish-0.0.0.dev121.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
479
- omlish-0.0.0.dev121.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
480
- omlish-0.0.0.dev121.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
481
- omlish-0.0.0.dev121.dist-info/RECORD,,
476
+ omlish-0.0.0.dev123.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
477
+ omlish-0.0.0.dev123.dist-info/METADATA,sha256=s67NY8EghL-Cm0sKC8CeitzxDwQw45JsvC8kTB8EGk0,4000
478
+ omlish-0.0.0.dev123.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
479
+ omlish-0.0.0.dev123.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
480
+ omlish-0.0.0.dev123.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
481
+ omlish-0.0.0.dev123.dist-info/RECORD,,