omlish 0.0.0.dev406__py3-none-any.whl → 0.0.0.dev408__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.
Files changed (66) hide show
  1. omlish/.manifests.json +2 -2
  2. omlish/__about__.py +2 -2
  3. omlish/asyncs/anyio/sync.py +3 -0
  4. omlish/asyncs/bluelet/runner.py +1 -0
  5. omlish/asyncs/bluelet/sockets.py +2 -0
  6. omlish/asyncs/sync.py +1 -0
  7. omlish/bootstrap/base.py +2 -0
  8. omlish/bootstrap/harness.py +1 -0
  9. omlish/codecs/text.py +1 -0
  10. omlish/collections/frozen.py +1 -0
  11. omlish/collections/mappings.py +2 -0
  12. omlish/collections/ordered.py +1 -0
  13. omlish/collections/sorted/sorted.py +1 -0
  14. omlish/collections/trie.py +2 -2
  15. omlish/concurrent/executors.py +1 -0
  16. omlish/dataclasses/tools/modifiers.py +1 -0
  17. omlish/diag/threads.py +1 -0
  18. omlish/formats/dotenv.py +5 -0
  19. omlish/formats/props.py +1 -0
  20. omlish/formats/toml/writer.py +1 -0
  21. omlish/formats/yaml.py +1 -0
  22. omlish/funcs/pipes.py +3 -0
  23. omlish/graphs/trees.py +1 -0
  24. omlish/http/jwt.py +2 -0
  25. omlish/http/multipart.py +1 -0
  26. omlish/inject/impl/injector.py +1 -0
  27. omlish/inject/lite.py +112 -0
  28. omlish/io/buffers.py +2 -0
  29. omlish/iterators/unique.py +1 -0
  30. omlish/lang/classes/restrict.py +1 -0
  31. omlish/lang/classes/simple.py +1 -0
  32. omlish/lang/contextmanagers.py +1 -0
  33. omlish/lang/descriptors.py +2 -0
  34. omlish/lang/imports/lazy.py +1 -1
  35. omlish/lang/imports/proxyinit.py +229 -122
  36. omlish/lang/objects.py +2 -0
  37. omlish/lang/resolving.py +1 -0
  38. omlish/lifecycles/contextmanagers.py +1 -0
  39. omlish/lite/cached.py +1 -0
  40. omlish/lite/inject.py +3 -0
  41. omlish/lite/secrets.py +1 -0
  42. omlish/logs/handlers.py +1 -0
  43. omlish/marshal/factories.py +2 -0
  44. omlish/marshal/polymorphism/metadata.py +2 -0
  45. omlish/marshal/registries.py +1 -0
  46. omlish/multiprocessing/spawn.py +3 -0
  47. omlish/secrets/openssl.py +2 -0
  48. omlish/secrets/secrets.py +5 -0
  49. omlish/specs/jmespath/errors.py +4 -0
  50. omlish/specs/jmespath/visitor.py +2 -0
  51. omlish/specs/jsonschema/keywords/base.py +1 -0
  52. omlish/sql/alchemy/apiadapter.py +1 -0
  53. omlish/sql/alchemy/asyncs.py +3 -0
  54. omlish/sql/alchemy/duckdb.py +2 -0
  55. omlish/sql/api/dbapi.py +2 -0
  56. omlish/sql/params.py +3 -0
  57. omlish/sql/queries/names.py +1 -0
  58. omlish/sync.py +3 -0
  59. omlish/testing/pytest/inject/harness.py +4 -2
  60. omlish/text/asdl.py +3 -0
  61. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/METADATA +1 -1
  62. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/RECORD +66 -65
  63. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/WHEEL +0 -0
  64. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/entry_points.txt +0 -0
  65. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/licenses/LICENSE +0 -0
  66. {omlish-0.0.0.dev406.dist-info → omlish-0.0.0.dev408.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,3 @@
1
- """
2
- TODO:
3
- - auto_proxy_init can capture `import as` by scanning globals for sentinels
4
- - replaces _AutoProxyInitCapture._attrs dict outright
5
- - should raise on unbound or shadowed import - was probably imported for side-effects but will never get
6
- proxy imported
7
- """
8
1
  import builtins
9
2
  import contextlib
10
3
  import functools
@@ -18,12 +11,11 @@ from ..lazyglobals import LazyGlobals
18
11
  ##
19
12
 
20
13
 
21
- class NamePackage(ta.NamedTuple):
22
- name: str
23
- package: str
24
-
25
-
26
14
  class _ProxyInit:
15
+ class NamePackage(ta.NamedTuple):
16
+ name: str
17
+ package: str
18
+
27
19
  class _Import(ta.NamedTuple):
28
20
  pkg: str
29
21
  attr: str | None
@@ -48,26 +40,16 @@ class _ProxyInit:
48
40
  def add(
49
41
  self,
50
42
  package: str,
51
- attrs: ta.Iterable[str | tuple[str, str]] | None = None,
43
+ attrs: ta.Iterable[tuple[str | None, str]],
52
44
  ) -> None:
53
- if isinstance(attrs, str):
54
- raise TypeError(attrs)
55
-
56
- if attrs is None:
57
- whole_attr = package.split('.')[-1]
45
+ for imp_attr, as_attr in attrs:
46
+ if imp_attr is None:
47
+ self._imps_by_attr[as_attr] = self._Import(package, None)
48
+ self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
58
49
 
59
- self._imps_by_attr[whole_attr] = self._Import(package, None)
60
- self._lazy_globals.set_fn(whole_attr, functools.partial(self.get, whole_attr))
61
-
62
- else:
63
- for attr in attrs:
64
- if isinstance(attr, tuple):
65
- imp_attr, attr = attr
66
- else:
67
- imp_attr = attr
68
-
69
- self._imps_by_attr[attr] = self._Import(package, imp_attr)
70
- self._lazy_globals.set_fn(attr, functools.partial(self.get, attr))
50
+ else:
51
+ self._imps_by_attr[as_attr] = self._Import(package, imp_attr)
52
+ self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
71
53
 
72
54
  def _import_module(self, name: str) -> ta.Any:
73
55
  return importlib.import_module(name, package=self._name_package.package)
@@ -98,12 +80,38 @@ class _ProxyInit:
98
80
  def proxy_init(
99
81
  init_globals: ta.MutableMapping[str, ta.Any],
100
82
  package: str,
101
- attrs: ta.Iterable[str | tuple[str, str]] | None = None,
83
+ attrs: ta.Iterable[str | tuple[str | None, str | None] | None] | None = None,
102
84
  ) -> None:
103
85
  if isinstance(attrs, str):
104
86
  raise TypeError(attrs)
105
87
 
106
- init_name_package = NamePackage(
88
+ if attrs is None:
89
+ attrs = [None]
90
+
91
+ whole_attr = package.split('.')[-1]
92
+ al: list[tuple[str | None, str]] = []
93
+ for attr in attrs:
94
+ if attr is None:
95
+ al.append((None, whole_attr))
96
+
97
+ elif isinstance(attr, str):
98
+ al.append((attr, attr))
99
+
100
+ elif isinstance(attr, tuple):
101
+ imp_attr, as_attr = attr
102
+ if as_attr is None:
103
+ if imp_attr is None:
104
+ as_attr = whole_attr
105
+ else:
106
+ as_attr = imp_attr
107
+ al.append((imp_attr, as_attr))
108
+
109
+ else:
110
+ raise TypeError(attr)
111
+
112
+ #
113
+
114
+ init_name_package = _ProxyInit.NamePackage(
107
115
  init_globals['__name__'],
108
116
  init_globals['__package__'],
109
117
  )
@@ -123,7 +131,7 @@ def proxy_init(
123
131
  if pi.name_package != init_name_package:
124
132
  raise Exception(f'Wrong init name: {pi.name_package=} != {init_name_package=}')
125
133
 
126
- pi.add(package, attrs)
134
+ pi.add(package, al)
127
135
 
128
136
 
129
137
  ##
@@ -166,6 +174,15 @@ class AutoProxyInitErrors:
166
174
  class UnproxiedImportForbiddenError(ImportError):
167
175
  pass
168
176
 
177
+ class UnreferencedImportsError(AutoProxyInitError):
178
+ def __init__(self, unreferenced: ta.Mapping[str, ta.Sequence[str | None]]) -> None:
179
+ super().__init__()
180
+
181
+ self.unreferenced = unreferenced
182
+
183
+ def __repr__(self) -> str:
184
+ return f'{self.__class__.__qualname__}(unreferenced={self.unreferenced!r})'
185
+
169
186
 
170
187
  class _AutoProxyInitCapture:
171
188
  class ModuleSpec(ta.NamedTuple):
@@ -178,8 +195,22 @@ class _AutoProxyInitCapture:
178
195
  def __repr__(self) -> str:
179
196
  return repr(str(self))
180
197
 
198
+ def __init__(self) -> None:
199
+ super().__init__()
200
+
201
+ self._modules_by_spec: dict[_AutoProxyInitCapture.ModuleSpec, _AutoProxyInitCapture._Module] = {}
202
+ self._modules_by_module_obj: dict[types.ModuleType, _AutoProxyInitCapture._Module] = {}
203
+
204
+ self._attrs: dict[_AutoProxyInitCapture._ModuleAttr, tuple[_AutoProxyInitCapture._Module, str]] = {}
205
+
206
+ #
207
+
181
208
  class _ModuleAttr:
182
- def __init__(self, module: '_AutoProxyInitCapture._Module', name: str) -> None:
209
+ def __init__(
210
+ self,
211
+ module: '_AutoProxyInitCapture._Module',
212
+ name: str,
213
+ ) -> None:
183
214
  super().__init__()
184
215
 
185
216
  self.__module = module
@@ -189,24 +220,62 @@ class _AutoProxyInitCapture:
189
220
  return f'<{self.__class__.__name__}: {f"{self.__module.spec}:{self.__name}"!r}>'
190
221
 
191
222
  class _Module:
192
- def __init__(self, spec: '_AutoProxyInitCapture.ModuleSpec') -> None:
223
+ def __init__(
224
+ self,
225
+ spec: '_AutoProxyInitCapture.ModuleSpec',
226
+ *,
227
+ getattr_handler: ta.Callable[['_AutoProxyInitCapture._Module', str], ta.Any] | None = None,
228
+ ) -> None:
193
229
  super().__init__()
194
230
 
195
231
  self.spec = spec
196
232
 
197
- self.module = types.ModuleType(f'<{self.__class__.__qualname__}: {spec!r}>')
233
+ self.module_obj = types.ModuleType(f'<{self.__class__.__qualname__}: {spec!r}>')
234
+ if getattr_handler is not None:
235
+ self.module_obj.__getattr__ = functools.partial(getattr_handler, self) # type: ignore[method-assign] # noqa
236
+ self.initial_module_dict = dict(self.module_obj.__dict__)
198
237
 
199
- self.attrs: dict[str, _AutoProxyInitCapture._ModuleAttr] = {}
238
+ self.contents: dict[str, _AutoProxyInitCapture._ModuleAttr | types.ModuleType] = {}
200
239
  self.imported_whole = False
201
240
 
202
241
  def __repr__(self) -> str:
203
242
  return f'{self.__class__.__name__}({self.spec!r})'
204
243
 
205
- def __init__(self) -> None:
206
- super().__init__()
244
+ def _get_or_make_module(self, spec: ModuleSpec) -> _Module:
245
+ try:
246
+ return self._modules_by_spec[spec]
247
+ except KeyError:
248
+ pass
207
249
 
208
- self._modules: dict[_AutoProxyInitCapture.ModuleSpec, _AutoProxyInitCapture._Module] = {}
209
- self._attrs: dict[str, _AutoProxyInitCapture._ModuleAttr | _AutoProxyInitCapture._Module] = {}
250
+ module = self._Module(
251
+ spec,
252
+ getattr_handler=self._handle_module_getattr,
253
+ )
254
+ self._modules_by_spec[spec] = module
255
+ self._modules_by_module_obj[module.module_obj] = module
256
+ return module
257
+
258
+ def _handle_module_getattr(self, module: _Module, attr: str) -> ta.Any:
259
+ if attr in module.contents:
260
+ raise AutoProxyInitErrors.AttrError(str(module.spec), attr)
261
+
262
+ v: _AutoProxyInitCapture._ModuleAttr | types.ModuleType
263
+ if not module.spec.name:
264
+ if not module.spec.level:
265
+ raise AutoProxyInitError
266
+ cs = _AutoProxyInitCapture.ModuleSpec(attr, module.spec.level)
267
+ cm = self._get_or_make_module(cs)
268
+ cm.imported_whole = True
269
+ v = cm.module_obj
270
+
271
+ else:
272
+ ma = _AutoProxyInitCapture._ModuleAttr(module, attr)
273
+ self._attrs[ma] = (module, attr)
274
+ v = ma
275
+
276
+ module.contents[attr] = v
277
+ setattr(module.module_obj, attr, v)
278
+ return v
210
279
 
211
280
  def _handle_import(
212
281
  self,
@@ -218,23 +287,6 @@ class _AutoProxyInitCapture:
218
287
  if module.spec.level or not module.spec.name:
219
288
  raise AutoProxyInitError
220
289
 
221
- attr = module.spec.name
222
-
223
- try:
224
- xma: ta.Any = self._attrs[attr]
225
- except KeyError:
226
- pass
227
-
228
- else:
229
- if (
230
- xma is not self._attrs.get(attr) or
231
- not module.imported_whole
232
- ):
233
- raise AutoProxyInitErrors.AttrError(str(module.spec), attr)
234
-
235
- return
236
-
237
- self._attrs[attr] = module
238
290
  module.imported_whole = True
239
291
 
240
292
  else:
@@ -242,27 +294,23 @@ class _AutoProxyInitCapture:
242
294
  if attr == '*':
243
295
  raise AutoProxyInitErrors.ImportStarForbiddenError(str(module.spec), from_list)
244
296
 
245
- try:
246
- xma = getattr(module.module, attr)
247
- except AttributeError:
248
- pass
249
-
297
+ x = getattr(module.module_obj, attr)
298
+
299
+ bad = False
300
+ if x is not module.contents.get(attr):
301
+ bad = True
302
+ if isinstance(x, _AutoProxyInitCapture._ModuleAttr):
303
+ if self._attrs[x] != (module, attr):
304
+ bad = True
305
+ elif isinstance(x, types.ModuleType):
306
+ if x not in self._modules_by_module_obj:
307
+ bad = True
250
308
  else:
251
- if (
252
- xma is not module.attrs.get(attr) or
253
- xma is not self._attrs.get(attr)
254
- ):
255
- raise AutoProxyInitErrors.AttrError(str(module.spec), attr)
256
-
257
- continue
258
-
259
- if attr in self._attrs:
309
+ bad = True
310
+ if bad:
260
311
  raise AutoProxyInitErrors.AttrError(str(module.spec), attr)
261
312
 
262
- ma = _AutoProxyInitCapture._ModuleAttr(module, attr)
263
- self._attrs[attr] = ma
264
- module.attrs[attr] = ma
265
- setattr(module.module, attr, ma)
313
+ #
266
314
 
267
315
  _MOD_SELF_ATTR: ta.ClassVar[str] = '__auto_proxy_init_capture__'
268
316
 
@@ -281,18 +329,14 @@ class _AutoProxyInitCapture:
281
329
  return None
282
330
 
283
331
  spec = _AutoProxyInitCapture.ModuleSpec(name, level)
284
- try:
285
- module = self._modules[spec]
286
- except KeyError:
287
- module = self._Module(spec)
288
- self._modules[spec] = module
332
+ module = self._get_or_make_module(spec)
289
333
 
290
334
  self._handle_import(
291
335
  module,
292
336
  from_list=from_list,
293
337
  )
294
338
 
295
- return module.module
339
+ return module.module_obj
296
340
 
297
341
  @contextlib.contextmanager
298
342
  def hook_context(
@@ -353,54 +397,103 @@ class _AutoProxyInitCapture:
353
397
  del init_globals[self._MOD_SELF_ATTR]
354
398
  builtins.__import__ = old_import
355
399
 
356
- def verify_globals(
400
+ #
401
+
402
+ def verify_state(
357
403
  self,
358
404
  init_globals: ta.MutableMapping[str, ta.Any], # noqa
359
405
  ) -> None:
360
- for attr, obj in self._attrs.items():
361
- try:
362
- xo = init_globals[attr]
363
- except KeyError:
364
- raise AutoProxyInitErrors.AttrError(None, attr) from None
406
+ for m in self._modules_by_spec.values():
407
+ for a, o in m.module_obj.__dict__.items():
408
+ try:
409
+ i = m.initial_module_dict[a]
365
410
 
366
- if isinstance(obj, _AutoProxyInitCapture._ModuleAttr):
367
- if xo is not obj:
368
- raise AutoProxyInitErrors.AttrError(None, attr) from None
411
+ except KeyError:
412
+ if o is not m.contents[a]:
413
+ raise AutoProxyInitErrors.AttrError(str(m.spec), a) from None
369
414
 
370
- elif isinstance(obj, _AutoProxyInitCapture._Module):
371
- if xo is not obj.module:
372
- raise AutoProxyInitErrors.AttrError(None, attr) from None
415
+ else:
416
+ if o != i:
417
+ raise AutoProxyInitErrors.AttrError(str(m.spec), a)
373
418
 
374
- else:
375
- raise TypeError(obj)
376
-
377
- @property
378
- def all_attrs(self) -> ta.AbstractSet[str]:
379
- return self._attrs.keys()
419
+ #
380
420
 
381
421
  class ProxyInit(ta.NamedTuple):
382
422
  package: str
383
- attrs: ta.Sequence[str] | None
423
+ attrs: ta.Sequence[tuple[str | None, str]]
384
424
 
385
- def build_proxy_inits(self) -> list[ProxyInit]:
386
- lst: list[_AutoProxyInitCapture.ProxyInit] = []
425
+ class BuiltProxyInits(ta.NamedTuple):
426
+ proxy_inits: ta.Sequence['_AutoProxyInitCapture.ProxyInit']
427
+ unreferenced: ta.Mapping[str, ta.Sequence[str | None]] | None
387
428
 
388
- for module in self._modules.values():
389
- if module.imported_whole:
390
- lst.append(_AutoProxyInitCapture.ProxyInit(str(module.spec), None))
429
+ def build_proxy_inits(
430
+ self,
431
+ init_globals: ta.MutableMapping[str, ta.Any], # noqa
432
+ *,
433
+ collect_unreferenced: bool = False,
434
+ ) -> BuiltProxyInits:
435
+ dct: dict[_AutoProxyInitCapture._Module, list[tuple[str | None, str]]] = {}
391
436
 
392
- if module.attrs:
393
- if not module.spec.name:
394
- for attr in module.attrs:
395
- if not module.spec.level:
396
- raise AutoProxyInitError
437
+ rem_whole_mods: set[_AutoProxyInitCapture._Module] = set()
438
+ rem_mod_attrs: set[_AutoProxyInitCapture._ModuleAttr] = set()
439
+ if collect_unreferenced:
440
+ rem_whole_mods.update([m for m in self._modules_by_spec.values() if m.imported_whole])
441
+ rem_mod_attrs.update(self._attrs)
397
442
 
398
- lst.append(_AutoProxyInitCapture.ProxyInit('.' * module.spec.level + attr, None))
443
+ for attr, obj in init_globals.items():
444
+ if isinstance(obj, _AutoProxyInitCapture._ModuleAttr):
445
+ try:
446
+ m, a = self._attrs[obj]
447
+ except KeyError:
448
+ raise AutoProxyInitErrors.AttrError(None, attr) from None
449
+ dct.setdefault(m, []).append((a, attr))
450
+ rem_mod_attrs.discard(obj)
399
451
 
400
- else:
401
- lst.append(_AutoProxyInitCapture.ProxyInit(str(module.spec), list(module.attrs)))
452
+ elif isinstance(obj, _AutoProxyInitCapture._Module):
453
+ raise AutoProxyInitErrors.AttrError(None, attr) from None
402
454
 
403
- return lst
455
+ elif isinstance(obj, types.ModuleType):
456
+ try:
457
+ m = self._modules_by_module_obj[obj]
458
+ except KeyError:
459
+ continue
460
+ if not m.imported_whole:
461
+ raise RuntimeError(f'AutoProxyInit module {m.spec!r} not imported_whole')
462
+ dct.setdefault(m, []).append((None, attr))
463
+ rem_whole_mods.discard(m)
464
+
465
+ lst: list[_AutoProxyInitCapture.ProxyInit] = []
466
+ for m, ts in dct.items():
467
+ if not m.spec.name:
468
+ if not m.spec.level:
469
+ raise AutoProxyInitError
470
+ for imp_attr, as_attr in ts:
471
+ if not imp_attr:
472
+ raise RuntimeError
473
+ lst.append(_AutoProxyInitCapture.ProxyInit(
474
+ '.' * m.spec.level + imp_attr,
475
+ [(None, as_attr)],
476
+ ))
477
+
478
+ else:
479
+ lst.append(_AutoProxyInitCapture.ProxyInit(
480
+ str(m.spec),
481
+ ts,
482
+ ))
483
+
484
+ unreferenced: dict[str, list[str | None]] | None = None
485
+ if collect_unreferenced and (rem_whole_mods or rem_mod_attrs):
486
+ unreferenced = {}
487
+ for m in rem_whole_mods:
488
+ unreferenced.setdefault(str(m.spec), []).append(None)
489
+ for ma in rem_mod_attrs:
490
+ m, a = self._attrs[ma]
491
+ unreferenced.setdefault(str(m.spec), []).append(a)
492
+
493
+ return _AutoProxyInitCapture.BuiltProxyInits(
494
+ lst,
495
+ unreferenced,
496
+ )
404
497
 
405
498
 
406
499
  @contextlib.contextmanager
@@ -409,6 +502,9 @@ def auto_proxy_init(
409
502
  *,
410
503
  disable: bool = False,
411
504
  eager: bool = False,
505
+
506
+ unreferenced_callback: ta.Callable[[ta.Mapping[str, ta.Sequence[str | None]]], None] | None = None,
507
+ raise_unreferenced: bool = False,
412
508
  ) -> ta.Iterator[None]:
413
509
  """
414
510
  This is a bit extreme - use sparingly. It relies on an interpreter-global import lock, but much of the ecosystem
@@ -425,14 +521,23 @@ def auto_proxy_init(
425
521
  with cap.hook_context(init_globals):
426
522
  yield
427
523
 
428
- cap.verify_globals(init_globals)
524
+ cap.verify_state(init_globals)
429
525
 
430
- pis = cap.build_proxy_inits()
526
+ blt = cap.build_proxy_inits(
527
+ init_globals,
528
+ collect_unreferenced=unreferenced_callback is not None or raise_unreferenced,
529
+ )
431
530
 
432
- for attr in cap.all_attrs:
433
- del init_globals[attr]
531
+ if blt.unreferenced:
532
+ if unreferenced_callback:
533
+ unreferenced_callback(blt.unreferenced)
534
+ if raise_unreferenced:
535
+ raise AutoProxyInitErrors.UnreferencedImportsError(blt.unreferenced)
536
+
537
+ for pi in blt.proxy_inits:
538
+ for _, a in pi.attrs:
539
+ del init_globals[a]
434
540
 
435
- for pi in pis:
436
541
  proxy_init(
437
542
  init_globals,
438
543
  pi.package,
@@ -441,5 +546,7 @@ def auto_proxy_init(
441
546
 
442
547
  if eager:
443
548
  lg = LazyGlobals.install(init_globals)
444
- for attr in cap.all_attrs:
445
- lg.get(attr)
549
+
550
+ for pi in blt.proxy_inits:
551
+ for _, a in pi.attrs:
552
+ lg.get(a)
omlish/lang/objects.py CHANGED
@@ -166,6 +166,7 @@ class SimpleProxy(ta.Generic[T]):
166
166
  class Descriptor:
167
167
  def __init__(self, attr: str) -> None:
168
168
  super().__init__()
169
+
169
170
  self._attr = attr
170
171
 
171
172
  def __get__(self, instance, owner=None):
@@ -189,6 +190,7 @@ class SimpleProxy(ta.Generic[T]):
189
190
 
190
191
  def __init__(self, wrapped: T) -> None:
191
192
  super().__init__()
193
+
192
194
  object.__setattr__(self, '__wrapped__', wrapped)
193
195
 
194
196
  def __init_subclass__(cls, **kwargs: ta.Any) -> None:
omlish/lang/resolving.py CHANGED
@@ -59,4 +59,5 @@ def get_fqcn_cls(fqcn: str, *, nocheck: bool = False) -> type:
59
59
  class Resolvable:
60
60
  def __init_subclass__(cls, **kwargs: ta.Any) -> None:
61
61
  super().__init_subclass__(**kwargs)
62
+
62
63
  get_cls_fqcn(cls, nocheck=True)
@@ -33,6 +33,7 @@ class ContextManagerLifecycle(Lifecycle, lang.Final, ta.Generic[ContextManagerT]
33
33
  class LifecycleContextManager(ta.Generic[LifecycleT]):
34
34
  def __init__(self, lifecycle: LifecycleT) -> None:
35
35
  super().__init__()
36
+
36
37
  self._lifecycle = lifecycle
37
38
  self._controller = lifecycle if isinstance(lifecycle, LifecycleController) else LifecycleController(lifecycle)
38
39
 
omlish/lite/cached.py CHANGED
@@ -13,6 +13,7 @@ CallableT = ta.TypeVar('CallableT', bound=ta.Callable)
13
13
  class _AbstractCachedNullary:
14
14
  def __init__(self, fn):
15
15
  super().__init__()
16
+
16
17
  self._fn = fn
17
18
  self._value = self._missing = object()
18
19
  functools.update_wrapper(self, fn)
omlish/lite/inject.py CHANGED
@@ -19,6 +19,7 @@ from .reflect import is_optional_alias
19
19
  T = ta.TypeVar('T')
20
20
  U = ta.TypeVar('U')
21
21
 
22
+
22
23
  InjectorKeyCls = ta.Union[type, ta.NewType]
23
24
 
24
25
  InjectorProviderFn = ta.Callable[['Injector'], ta.Any]
@@ -402,6 +403,7 @@ class ContextvarInjectorScope(InjectorScope, abc.ABC):
402
403
 
403
404
  def __init_subclass__(cls, **kwargs: ta.Any) -> None:
404
405
  super().__init_subclass__(**kwargs)
406
+
405
407
  check.not_in(abc.ABC, cls.__bases__)
406
408
  check.state(not hasattr(cls, '_cv'))
407
409
  cls._cv = contextvars.ContextVar(f'{cls.__name__}_cv')
@@ -676,6 +678,7 @@ class _Injector(Injector):
676
678
  class _Request:
677
679
  def __init__(self, injector: '_Injector') -> None:
678
680
  super().__init__()
681
+
679
682
  self._injector = injector
680
683
  self._provisions: ta.Dict[InjectorKey, Maybe] = {}
681
684
  self._seen_keys: ta.Set[InjectorKey] = set()
omlish/lite/secrets.py CHANGED
@@ -12,6 +12,7 @@ class Secret:
12
12
 
13
13
  def __init__(self, *, key: ta.Optional[str] = None, value: str) -> None:
14
14
  super().__init__()
15
+
15
16
  self._key = key
16
17
  setattr(self, self._VALUE_ATTR, lambda: value)
17
18
 
omlish/logs/handlers.py CHANGED
@@ -10,6 +10,7 @@ import typing as ta
10
10
  class ListHandler(logging.Handler):
11
11
  def __init__(self) -> None:
12
12
  super().__init__()
13
+
13
14
  self.records: ta.List[logging.LogRecord] = []
14
15
 
15
16
  def emit(self, record: logging.LogRecord) -> None:
@@ -41,6 +41,7 @@ class TypeMapFactory(mfs.MatchFn[[C, rfl.Type], R]):
41
41
  class TypeCacheFactory(mfs.MatchFn[[C, rfl.Type], R]):
42
42
  def __init__(self, f: mfs.MatchFn[[C, rfl.Type], R]) -> None:
43
43
  super().__init__()
44
+
44
45
  self._f = f
45
46
  self._dct: dict[rfl.Type, R | None] = {}
46
47
  self._mtx = threading.RLock()
@@ -90,6 +91,7 @@ class RecursiveTypeFactory(mfs.MatchFn[[C, rfl.Type], R]):
90
91
  prx: ta.Callable[[], tuple[R, ta.Callable[[R], None]]],
91
92
  ) -> None:
92
93
  super().__init__()
94
+
93
95
  self._f = f
94
96
  self._prx = prx
95
97
  self._dct: dict[rfl.Type, R] = {}
@@ -39,6 +39,7 @@ class Impls(ta.Sequence[Impl]):
39
39
  lst: ta.Iterable[Impl],
40
40
  ) -> None:
41
41
  super().__init__()
42
+
42
43
  self._lst = list(lst)
43
44
 
44
45
  by_ty: dict[type, Impl] = {}
@@ -89,6 +90,7 @@ class Polymorphism:
89
90
  impls: ta.Iterable[Impl],
90
91
  ) -> None:
91
92
  super().__init__()
93
+
92
94
  self._ty = ty
93
95
  self._impls = Impls(impls)
94
96
 
@@ -35,6 +35,7 @@ class _KeyRegistryItems:
35
35
  class Registry:
36
36
  def __init__(self) -> None:
37
37
  super().__init__()
38
+
38
39
  self._mtx = threading.Lock()
39
40
  self._idct: ta.MutableMapping[ta.Any, _KeyRegistryItems] = col.IdentityKeyDict()
40
41
  self._dct: dict[ta.Any, _KeyRegistryItems] = {}
@@ -24,6 +24,7 @@ class ExtrasSpawnPosixPopen(mp.popen_spawn_posix.Popen):
24
24
  def __init__(self, process_obj: 'ExtrasSpawnProcess', *, extras: SpawnExtras) -> None:
25
25
  self.__extras = extras
26
26
  self.__pass_fds = extras.pass_fds
27
+
27
28
  super().__init__(process_obj)
28
29
 
29
30
  def _launch(self, process_obj: 'ExtrasSpawnProcess') -> None:
@@ -38,6 +39,7 @@ class ExtrasSpawnPosixPopen(mp.popen_spawn_posix.Popen):
38
39
  class ExtrasSpawnProcess(mp.context.SpawnProcess):
39
40
  def __init__(self, *args: ta.Any, extras: SpawnExtras, **kwargs: ta.Any) -> None:
40
41
  self.__extras = extras
42
+
41
43
  super().__init__(*args, **kwargs)
42
44
 
43
45
  def _Popen(self, process_obj: 'ExtrasSpawnProcess') -> ExtrasSpawnPosixPopen: # type: ignore # noqa
@@ -56,6 +58,7 @@ class ExtrasSpawnProcess(mp.context.SpawnProcess):
56
58
  class ExtrasSpawnContext(mp.context.SpawnContext):
57
59
  def __init__(self, extras: SpawnExtras = SpawnExtras()) -> None:
58
60
  self.__extras = extras
61
+
59
62
  super().__init__()
60
63
 
61
64
  def Process(self, *args: ta.Any, **kwargs: ta.Any): # type: ignore # noqa
omlish/secrets/openssl.py CHANGED
@@ -56,6 +56,7 @@ class OpensslAescbcCrypto(Crypto):
56
56
  iters: int = 10_000,
57
57
  ) -> None:
58
58
  super().__init__()
59
+
59
60
  self._iters = iters
60
61
 
61
62
  def generate_key(self, sz: int = DEFAULT_KEY_SIZE) -> bytes:
@@ -131,6 +132,7 @@ class OpensslSubprocessAescbcCrypto(Crypto):
131
132
  file_input: SubprocessFileInputMethod = temp_subprocess_file_input,
132
133
  ) -> None:
133
134
  super().__init__()
135
+
134
136
  self._cmd = cmd
135
137
  self._timeout = timeout
136
138
  self._file_input = file_input