omlish 0.0.0.dev68__py3-none-any.whl → 0.0.0.dev69__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.dev68'
2
- __revision__ = '60a77b10e4421b5bcc3597af79e50d5c8ab4d924'
1
+ __version__ = '0.0.0.dev69'
2
+ __revision__ = '3097a2b32b2d2b25ce6a2ae4d289e3b6f6447538'
3
3
 
4
4
 
5
5
  #
omlish/lang/imports.py CHANGED
@@ -12,7 +12,12 @@ from .cached import cached_function
12
12
 
13
13
 
14
14
  def can_import(name: str, package: str | None = None) -> bool:
15
- return importlib.util.find_spec(name, package) is not None
15
+ try:
16
+ spec = importlib.util.find_spec(name, package)
17
+ except ImportError:
18
+ return False
19
+ else:
20
+ return spec is not None
16
21
 
17
22
 
18
23
  ##
@@ -22,13 +27,23 @@ def lazy_import(name: str, package: str | None = None) -> ta.Callable[[], ta.Any
22
27
  return cached_function(functools.partial(importlib.import_module, name, package=package))
23
28
 
24
29
 
25
- def proxy_import(name: str, package: str | None = None) -> types.ModuleType:
30
+ def proxy_import(
31
+ name: str,
32
+ package: str | None = None,
33
+ extras: ta.Iterable[str] | None = None,
34
+ ) -> types.ModuleType:
35
+ if isinstance(extras, str):
36
+ raise TypeError(extras)
37
+
26
38
  omod = None
27
39
 
28
40
  def __getattr__(att): # noqa
29
41
  nonlocal omod
30
42
  if omod is None:
31
43
  omod = importlib.import_module(name, package=package)
44
+ if extras:
45
+ for x in extras:
46
+ importlib.import_module(f'{name}.{x}', package=package)
32
47
  return getattr(omod, att)
33
48
 
34
49
  lmod = types.ModuleType(name)
omlish/lang/objects.py CHANGED
@@ -87,7 +87,7 @@ def super_meta(
87
87
  ##
88
88
 
89
89
 
90
- def deep_subclasses(cls: type, *, concrete_only: bool = False) -> ta.Iterator[type]:
90
+ def deep_subclasses(cls: type[T], *, concrete_only: bool = False) -> ta.Iterator[type[T]]:
91
91
  seen = set()
92
92
  todo = list(reversed(cls.__subclasses__()))
93
93
  while todo:
omlish/libc.py CHANGED
@@ -1,4 +1,4 @@
1
- # ruff: noqa: ANN201, N801, N802
1
+ # ruff: noqa: ANN201 N801 N802
2
2
  import ctypes as ct
3
3
  import errno
4
4
  import platform
@@ -1,7 +1,6 @@
1
1
  from .testing import ( # noqa
2
2
  assert_dicts_equal_ordered,
3
3
  call_many_with_timeout,
4
- can_import,
5
4
  run_with_timeout,
6
5
  waitpid_with_timeout,
7
6
  xfail,
@@ -37,7 +37,7 @@ class ManagerMarksPlugin:
37
37
  def mark_classes(self) -> ta.Mapping[str, type[ManagerMark]]:
38
38
  return {
39
39
  cls.__name__: cls
40
- for cls in _deep_subclasses(ManagerMark)
40
+ for cls in lang.deep_subclasses(ManagerMark) # type: ignore[type-abstract]
41
41
  if not lang.is_abstract_class(cls)
42
42
  }
43
43
 
@@ -5,11 +5,11 @@ import typing as ta
5
5
 
6
6
  import pytest
7
7
 
8
- from ..testing import can_import
8
+ from ... import lang
9
9
 
10
10
 
11
11
  def if_cant_import(module: str, *args, **kwargs):
12
- return pytest.mark.skipif(not can_import(module, *args, **kwargs), reason=f'requires import {module}')
12
+ return pytest.mark.skipif(not lang.can_import(module, *args, **kwargs), reason=f'requires import {module}')
13
13
 
14
14
 
15
15
  def if_not_on_path(exe: str):
omlish/testing/testing.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import functools
2
- import importlib
3
2
  import os
4
3
  import sys
5
4
  import threading
@@ -89,15 +88,6 @@ def waitpid_with_timeout(
89
88
  raise timeout_exception
90
89
 
91
90
 
92
- def can_import(*args, **kwargs) -> bool:
93
- try:
94
- importlib.import_module(*args, **kwargs)
95
- except ImportError:
96
- return False
97
- else:
98
- return True
99
-
100
-
101
91
  def xfail(fn):
102
92
  @functools.wraps(fn)
103
93
  def inner(*args, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omlish
3
- Version: 0.0.0.dev68
3
+ Version: 0.0.0.dev69
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=TXvFdkAU0Zr2FKdo7fyvt9nr3UjCtrnAZ0diZXSAteE,1430
2
- omlish/__about__.py,sha256=Lo42shN4zusm7eF0NYiY81TzhZ8cDCXTIRZnGyGtd-Q,3420
2
+ omlish/__about__.py,sha256=IwGGP6Oe4Sux6iaJWcinkD3DfkrJmksEYnKmYdTly1I,3420
3
3
  omlish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  omlish/argparse.py,sha256=Dc73G8lyoQBLvXhMYUbzQUh4SJu_OTvKUXjSUxq_ang,7499
5
5
  omlish/c3.py,sha256=4vogWgwPb8TbNS2KkZxpoWbwjj7MuHG2lQG-hdtkvjI,8062
@@ -12,7 +12,7 @@ omlish/fnpairs.py,sha256=Sl8CMFNyDS-1JYAjSWqnT5FmUm9Lj6o7FxSRo7g4jww,10875
12
12
  omlish/fnpipes.py,sha256=AJkgz9nvRRm7oqw7ZgYyz21klu276LWi54oYCLg-vOg,2196
13
13
  omlish/genmachine.py,sha256=LCMiqvK32dAWtrlB6lKw9tXdQFiXC8rRdk4TMQYIroU,1603
14
14
  omlish/iterators.py,sha256=GGLC7RIT86uXMjhIIIqnff_Iu5SI_b9rXYywYGFyzmo,7292
15
- omlish/libc.py,sha256=QSqAauv4o77T_ttyC6I4M-q33VROHjbZtkN-lEWJ6RU,15364
15
+ omlish/libc.py,sha256=8r7Ejyhttk9ruCfBkxNTrlzir5WPbDE2vmY7VPlceMA,15362
16
16
  omlish/matchfns.py,sha256=I1IlQGfEyk_AcFSy6ulVS3utC-uwyZM2YfUXYHc9Bw0,6152
17
17
  omlish/multiprocessing.py,sha256=QZT4C7I-uThCAjaEY3xgUYb-5GagUlnE4etN01LDyU4,5186
18
18
  omlish/os.py,sha256=vO1sZCzAhVxo46tDFLrD52q2KuMFWQwu5MPJgSsnliI,3107
@@ -249,10 +249,10 @@ omlish/lang/datetimes.py,sha256=ehI_DhQRM-bDxAavnp470XcekbbXc4Gdw9y1KpHDJT0,223
249
249
  omlish/lang/descriptors.py,sha256=RRBbkMgTzg82fFFE4D0muqobpM-ZZaOta6yB1lpX3s8,6617
250
250
  omlish/lang/exceptions.py,sha256=qJBo3NU1mOWWm-NhQUHCY5feYXR3arZVyEHinLsmRH4,47
251
251
  omlish/lang/functions.py,sha256=kkPfcdocg-OmyN7skIqrFxNvqAv89Zc_kXKYAN8vw8g,3895
252
- omlish/lang/imports.py,sha256=04ugFC8NI5sbL7NH4V0r0q_nFsP_AMkHLz697CVkMtQ,6274
252
+ omlish/lang/imports.py,sha256=Oy7iInOTqgZv6nyRbnvGrPv4cKKIAzPbhfDXCajDUcc,6626
253
253
  omlish/lang/iterables.py,sha256=_q6rHbdFfW3VBqez0IV3rUABoNxsA_oBv_sykm5zsbQ,2243
254
254
  omlish/lang/maybes.py,sha256=NYHZDjqDtwPMheDrj2VtUVujxRPf8Qpgk4ZlZCTvBZc,3492
255
- omlish/lang/objects.py,sha256=PJXGm-WgC7vpWzaXGwofk48V2XZNaQLje60K1ariwvQ,4454
255
+ omlish/lang/objects.py,sha256=t7Pvj9ILoxfdAMy5HC7bb9LfUokW5WfpLaoH2YYyTjQ,4460
256
256
  omlish/lang/resolving.py,sha256=OuN2mDTPNyBUbcrswtvFKtj4xgH4H4WglgqSKv3MTy0,1606
257
257
  omlish/lang/resources.py,sha256=-NmVTrSMKFZ6smVfOMz46ekZYVGgYh8cPooxQlFpG6s,2135
258
258
  omlish/lang/strings.py,sha256=BsciSYnckD4vGtC6kmtnugR9IN6CIHdcjO4nZu-pSAw,3898
@@ -386,12 +386,12 @@ omlish/sql/alchemy/duckdb.py,sha256=kr7pIhiBLNAuZrcigHDtFg9zHkVcrRW3LfryO9VJ4mk,
386
386
  omlish/sql/alchemy/exprs.py,sha256=gO4Fj4xEY-PuDgV-N8hBMy55glZz7O-4H7v1LWabfZY,323
387
387
  omlish/sql/alchemy/secrets.py,sha256=EMfy4EfTbEvrlv_41oOhn8qsoF-eTkY7HciPenIE6rI,178
388
388
  omlish/sql/alchemy/sqlean.py,sha256=RbkuOuFIfM4fowwKk8-sQ6Dxk-tTUwxS94nY5Kxt52s,403
389
- omlish/testing/__init__.py,sha256=kfiF10ykrjWXniedIl3g8j3pNAFyuSbp1D3ZXug3-Eo,168
390
- omlish/testing/testing.py,sha256=pJUbZ0ymdrQoNG9r9UlGXypeU1x9ntEp9xcYBnyOHUs,3088
389
+ omlish/testing/__init__.py,sha256=M_BQrcCHkoL-ZvE-UpQ8XxXNYRRawhjUz4rCJnAqM2A,152
390
+ omlish/testing/testing.py,sha256=TT2wwSzPZ_KhIvKxpM1qc1yHKD-LHDNgGrcr_h8vs7c,2895
391
391
  omlish/testing/pytest/__init__.py,sha256=B2nyJrjIoNcEopbg0IZ5UUDs4OHmQ8qqElFJfGcDdas,257
392
392
  omlish/testing/pytest/helpers.py,sha256=TJpD60mBtLi9FtxX4TThfuXvg5FIRPSiZk1aeRwe-D4,197
393
393
  omlish/testing/pytest/marks.py,sha256=ExuwitbMr1txMbaAcWZ652pYa30M-i3wVacnjqschTs,424
394
- omlish/testing/pytest/skip.py,sha256=uACMFtQQNJfFDbWrppjWevdrQgKVH1MUmH5rXIpv0IE,846
394
+ omlish/testing/pytest/skip.py,sha256=NxTkAQiS3HKZR3sfFdxOR2LCFwtCveY6Ap-qtexiZbw,839
395
395
  omlish/testing/pytest/inject/__init__.py,sha256=pdRKv1HcDmJ_yArKJbYITPXXZthRSGgBJWqITr0Er38,117
396
396
  omlish/testing/pytest/inject/harness.py,sha256=v4DaKJ0KL8oQjzIMK43Gh8GHP4hiI6-lY37O9lyOHRk,5724
397
397
  omlish/testing/pytest/plugins/__init__.py,sha256=ys1zXrYrNm7Uo6YOIVJ6Bd3dQo6kv387k7MbTYlqZSI,467
@@ -399,7 +399,7 @@ omlish/testing/pytest/plugins/_registry.py,sha256=IK04KlBgiOJxKAyCCgjpX2R-9tE-bt
399
399
  omlish/testing/pytest/plugins/asyncs.py,sha256=SV6oKCy50CGkzLGYX-CT4MfWNqsrH8ONEbIWC3tFcHA,5324
400
400
  omlish/testing/pytest/plugins/depskip.py,sha256=xithY-OMtjwhv8mcRNkv-WI_PSQtHldQ8H1s60MIXkk,2673
401
401
  omlish/testing/pytest/plugins/logging.py,sha256=1zs6Xe54wiaSjabCviaFXwKkoN97CKm3mA5mEoUeJGs,380
402
- omlish/testing/pytest/plugins/managermarks.py,sha256=pDEcCNdDAcTS4jjZHSnAfmzqMJDBcJcSsM3QNhbJ6Gs,1485
402
+ omlish/testing/pytest/plugins/managermarks.py,sha256=AP3ty-QB-8O5DkulwUOudBlUOvXMHhBfNyY-0yCmejk,1520
403
403
  omlish/testing/pytest/plugins/pydevd.py,sha256=u1fxfCgFw4wGKBkMV_H_l9WI8JoUwlRff4iHEr_WYeE,319
404
404
  omlish/testing/pytest/plugins/repeat.py,sha256=flSQzE9GFOWksVKz-mUGnpxJpv3yRqn1G4K8pW7JHs0,498
405
405
  omlish/testing/pytest/plugins/skips.py,sha256=EoZDg1uWccgbAegmzqI85c7RliycD1e2J4Y7vfDRhwM,1041
@@ -412,9 +412,9 @@ omlish/text/delimit.py,sha256=ubPXcXQmtbOVrUsNh5gH1mDq5H-n1y2R4cPL5_DQf68,4928
412
412
  omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,3296
413
413
  omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
414
414
  omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
415
- omlish-0.0.0.dev68.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
416
- omlish-0.0.0.dev68.dist-info/METADATA,sha256=dB7UaEa5BlDr9UDJLwPaobs83TJrglLK7JxNHdDYlAI,4167
417
- omlish-0.0.0.dev68.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
418
- omlish-0.0.0.dev68.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
419
- omlish-0.0.0.dev68.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
420
- omlish-0.0.0.dev68.dist-info/RECORD,,
415
+ omlish-0.0.0.dev69.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
416
+ omlish-0.0.0.dev69.dist-info/METADATA,sha256=60bC4G8a17heJL6mUwr4rCB1VrowRiVCdww0ArlUTXk,4167
417
+ omlish-0.0.0.dev69.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
418
+ omlish-0.0.0.dev69.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
419
+ omlish-0.0.0.dev69.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
420
+ omlish-0.0.0.dev69.dist-info/RECORD,,