omdev 0.0.0.dev439__py3-none-any.whl → 0.0.0.dev441__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.
@@ -188,7 +188,7 @@
188
188
  "module": ".py.attrdocs",
189
189
  "attr": "_CLI_MODULE",
190
190
  "file": "omdev/py/attrdocs.py",
191
- "line": 160,
191
+ "line": 159,
192
192
  "value": {
193
193
  "!.cli.types.CliModule": {
194
194
  "name": "py/attrdocs",
@@ -90,6 +90,7 @@ class GithubCacheServiceV2:
90
90
  class CreateCacheEntryResponse:
91
91
  ok: bool
92
92
  signed_upload_url: str
93
+ message: ta.Optional[str] = None
93
94
 
94
95
  CREATE_CACHE_ENTRY_METHOD: Method[
95
96
  CreateCacheEntryRequest,
@@ -113,6 +114,7 @@ class GithubCacheServiceV2:
113
114
  class FinalizeCacheEntryUploadResponse:
114
115
  ok: bool
115
116
  entry_id: str
117
+ message: ta.Optional[str] = None
116
118
 
117
119
  FINALIZE_CACHE_ENTRY_METHOD: Method[
118
120
  FinalizeCacheEntryUploadRequest,
@@ -227,6 +227,62 @@ def async_cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
227
227
  return _AsyncCachedNullary(fn)
228
228
 
229
229
 
230
+ ##
231
+
232
+
233
+ cached_property = functools.cached_property
234
+
235
+
236
+ class _cached_property: # noqa
237
+ """Backported to pick up https://github.com/python/cpython/commit/056dfc71dce15f81887f0bd6da09d6099d71f979 ."""
238
+
239
+ def __init__(self, func):
240
+ self.func = func
241
+ self.attrname = None # noqa
242
+ self.__doc__ = func.__doc__
243
+ self.__module__ = func.__module__
244
+
245
+ _NOT_FOUND = object()
246
+
247
+ def __set_name__(self, owner, name):
248
+ if self.attrname is None:
249
+ self.attrname = name # noqa
250
+ elif name != self.attrname:
251
+ raise TypeError(
252
+ f'Cannot assign the same cached_property to two different names ({self.attrname!r} and {name!r}).',
253
+ )
254
+
255
+ def __get__(self, instance, owner=None):
256
+ if instance is None:
257
+ return self
258
+ if self.attrname is None:
259
+ raise TypeError('Cannot use cached_property instance without calling __set_name__ on it.')
260
+
261
+ try:
262
+ cache = instance.__dict__
263
+ except AttributeError: # not all objects have __dict__ (e.g. class defines slots)
264
+ raise TypeError(
265
+ f"No '__dict__' attribute on {type(instance).__name__!r} instance to cache {self.attrname!r} property.",
266
+ ) from None
267
+
268
+ val = cache.get(self.attrname, self._NOT_FOUND)
269
+
270
+ if val is self._NOT_FOUND:
271
+ val = self.func(instance)
272
+ try:
273
+ cache[self.attrname] = val
274
+ except TypeError:
275
+ raise TypeError(
276
+ f"The '__dict__' attribute on {type(instance).__name__!r} instance does not support item "
277
+ f"assignment for caching {self.attrname!r} property.",
278
+ ) from None
279
+
280
+ return val
281
+
282
+
283
+ globals()['cached_property'] = _cached_property
284
+
285
+
230
286
  ########################################
231
287
  # ../../../omlish/lite/check.py
232
288
  """
omdev/py/attrdocs.py CHANGED
@@ -24,12 +24,11 @@ class AttrDoc:
24
24
  trailing_comment: str | None = None
25
25
  preceding_comment: str | None = None
26
26
 
27
- __repr__ = lang.attr_ops(
28
- 'docstring',
29
- 'trailing_comment',
30
- 'preceding_comment',
31
- repr_filter=bool,
32
- ).repr
27
+ __repr__ = lang.attr_ops(lambda o: (
28
+ o.docstring,
29
+ o.trailing_comment,
30
+ o.preceding_comment,
31
+ ), repr_filter=bool).repr
33
32
 
34
33
 
35
34
  _EMPTY_ATTR_DOC = AttrDoc()
omdev/scripts/ci.py CHANGED
@@ -670,6 +670,62 @@ def async_cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
670
670
  return _AsyncCachedNullary(fn)
671
671
 
672
672
 
673
+ ##
674
+
675
+
676
+ cached_property = functools.cached_property
677
+
678
+
679
+ class _cached_property: # noqa
680
+ """Backported to pick up https://github.com/python/cpython/commit/056dfc71dce15f81887f0bd6da09d6099d71f979 ."""
681
+
682
+ def __init__(self, func):
683
+ self.func = func
684
+ self.attrname = None # noqa
685
+ self.__doc__ = func.__doc__
686
+ self.__module__ = func.__module__
687
+
688
+ _NOT_FOUND = object()
689
+
690
+ def __set_name__(self, owner, name):
691
+ if self.attrname is None:
692
+ self.attrname = name # noqa
693
+ elif name != self.attrname:
694
+ raise TypeError(
695
+ f'Cannot assign the same cached_property to two different names ({self.attrname!r} and {name!r}).',
696
+ )
697
+
698
+ def __get__(self, instance, owner=None):
699
+ if instance is None:
700
+ return self
701
+ if self.attrname is None:
702
+ raise TypeError('Cannot use cached_property instance without calling __set_name__ on it.')
703
+
704
+ try:
705
+ cache = instance.__dict__
706
+ except AttributeError: # not all objects have __dict__ (e.g. class defines slots)
707
+ raise TypeError(
708
+ f"No '__dict__' attribute on {type(instance).__name__!r} instance to cache {self.attrname!r} property.",
709
+ ) from None
710
+
711
+ val = cache.get(self.attrname, self._NOT_FOUND)
712
+
713
+ if val is self._NOT_FOUND:
714
+ val = self.func(instance)
715
+ try:
716
+ cache[self.attrname] = val
717
+ except TypeError:
718
+ raise TypeError(
719
+ f"The '__dict__' attribute on {type(instance).__name__!r} instance does not support item "
720
+ f"assignment for caching {self.attrname!r} property.",
721
+ ) from None
722
+
723
+ return val
724
+
725
+
726
+ globals()['cached_property'] = _cached_property
727
+
728
+
673
729
  ########################################
674
730
  # ../../../omlish/lite/check.py
675
731
  """
@@ -1366,6 +1422,17 @@ aclosing = AsyncClosingManager
1366
1422
  ##
1367
1423
 
1368
1424
 
1425
+ def dataclass_shallow_astuple(o: ta.Any) -> ta.Tuple[ta.Any, ...]:
1426
+ return tuple(getattr(o, f.name) for f in dc.fields(o))
1427
+
1428
+
1429
+ def dataclass_shallow_asdict(o: ta.Any) -> ta.Dict[str, ta.Any]:
1430
+ return {f.name: getattr(o, f.name) for f in dc.fields(o)}
1431
+
1432
+
1433
+ ##
1434
+
1435
+
1369
1436
  def is_immediate_dataclass(cls: type) -> bool:
1370
1437
  if not isinstance(cls, type):
1371
1438
  raise TypeError(cls)
@@ -2547,6 +2614,7 @@ class GithubCacheServiceV2:
2547
2614
  class CreateCacheEntryResponse:
2548
2615
  ok: bool
2549
2616
  signed_upload_url: str
2617
+ message: ta.Optional[str] = None
2550
2618
 
2551
2619
  CREATE_CACHE_ENTRY_METHOD: Method[
2552
2620
  CreateCacheEntryRequest,
@@ -2570,6 +2638,7 @@ class GithubCacheServiceV2:
2570
2638
  class FinalizeCacheEntryUploadResponse:
2571
2639
  ok: bool
2572
2640
  entry_id: str
2641
+ message: ta.Optional[str] = None
2573
2642
 
2574
2643
  FINALIZE_CACHE_ENTRY_METHOD: Method[
2575
2644
  FinalizeCacheEntryUploadRequest,
@@ -3252,6 +3321,70 @@ class ArgparseCli:
3252
3321
  return fn()
3253
3322
 
3254
3323
 
3324
+ ########################################
3325
+ # ../../../omlish/http/coro/io.py
3326
+
3327
+
3328
+ ##
3329
+
3330
+
3331
+ class CoroHttpIo:
3332
+ def __new__(cls, *args, **kwargs): # noqa
3333
+ raise TypeError
3334
+
3335
+ def __init_subclass__(cls, **kwargs): # noqa
3336
+ raise TypeError
3337
+
3338
+ #
3339
+
3340
+ MAX_LINE: ta.ClassVar[int] = 65536
3341
+
3342
+ #
3343
+
3344
+ class Io(Abstract):
3345
+ pass
3346
+
3347
+ #
3348
+
3349
+ class AnyLogIo(Io, Abstract):
3350
+ pass
3351
+
3352
+ #
3353
+
3354
+ @dc.dataclass(frozen=True)
3355
+ class ConnectIo(Io):
3356
+ args: ta.Tuple[ta.Any, ...]
3357
+ kwargs: ta.Optional[ta.Dict[str, ta.Any]] = None
3358
+
3359
+ #
3360
+
3361
+ class CloseIo(Io):
3362
+ pass
3363
+
3364
+ #
3365
+
3366
+ class AnyReadIo(Io): # noqa
3367
+ pass
3368
+
3369
+ @dc.dataclass(frozen=True)
3370
+ class ReadIo(AnyReadIo):
3371
+ sz: ta.Optional[int]
3372
+
3373
+ @dc.dataclass(frozen=True)
3374
+ class ReadLineIo(AnyReadIo):
3375
+ sz: int
3376
+
3377
+ @dc.dataclass(frozen=True)
3378
+ class PeekIo(AnyReadIo):
3379
+ sz: int
3380
+
3381
+ #
3382
+
3383
+ @dc.dataclass(frozen=True)
3384
+ class WriteIo(Io):
3385
+ data: bytes
3386
+
3387
+
3255
3388
  ########################################
3256
3389
  # ../../../omlish/http/parsing.py
3257
3390
  # PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -9245,48 +9378,21 @@ class CoroHttpServer:
9245
9378
 
9246
9379
  #
9247
9380
 
9248
- class Io(Abstract):
9249
- pass
9250
-
9251
- #
9252
-
9253
- class AnyLogIo(Io):
9254
- pass
9255
-
9256
9381
  @dc.dataclass(frozen=True)
9257
- class ParsedRequestLogIo(AnyLogIo):
9382
+ class ParsedRequestLogIo(CoroHttpIo.AnyLogIo):
9258
9383
  request: ParsedHttpRequest
9259
9384
 
9260
9385
  @dc.dataclass(frozen=True)
9261
- class ErrorLogIo(AnyLogIo):
9386
+ class ErrorLogIo(CoroHttpIo.AnyLogIo):
9262
9387
  error: 'CoroHttpServer.Error'
9263
9388
 
9264
9389
  #
9265
9390
 
9266
- class AnyReadIo(Io): # noqa
9267
- pass
9268
-
9269
- @dc.dataclass(frozen=True)
9270
- class ReadIo(AnyReadIo):
9271
- sz: int
9272
-
9273
- @dc.dataclass(frozen=True)
9274
- class ReadLineIo(AnyReadIo):
9275
- sz: int
9276
-
9277
- #
9278
-
9279
- @dc.dataclass(frozen=True)
9280
- class WriteIo(Io):
9281
- data: bytes
9282
-
9283
- #
9284
-
9285
9391
  @dc.dataclass(frozen=True)
9286
9392
  class CoroHandleResult:
9287
9393
  close_reason: ta.Literal['response', 'internal', None] = None
9288
9394
 
9289
- def coro_handle(self) -> ta.Generator[Io, ta.Optional[bytes], CoroHandleResult]:
9395
+ def coro_handle(self) -> ta.Generator[CoroHttpIo.Io, ta.Optional[bytes], CoroHandleResult]:
9290
9396
  return self._coro_run_handler(self._coro_handle_one())
9291
9397
 
9292
9398
  class Close(Exception): # noqa
@@ -9295,20 +9401,20 @@ class CoroHttpServer:
9295
9401
  def _coro_run_handler(
9296
9402
  self,
9297
9403
  gen: ta.Generator[
9298
- ta.Union[AnyLogIo, AnyReadIo, _Response],
9404
+ ta.Union[CoroHttpIo.AnyLogIo, CoroHttpIo.AnyReadIo, _Response],
9299
9405
  ta.Optional[bytes],
9300
9406
  None,
9301
9407
  ],
9302
- ) -> ta.Generator[Io, ta.Optional[bytes], CoroHandleResult]:
9408
+ ) -> ta.Generator[CoroHttpIo.Io, ta.Optional[bytes], CoroHandleResult]:
9303
9409
  i: ta.Optional[bytes]
9304
9410
  o: ta.Any = next(gen)
9305
9411
  while True:
9306
9412
  try:
9307
- if isinstance(o, self.AnyLogIo):
9413
+ if isinstance(o, CoroHttpIo.AnyLogIo):
9308
9414
  i = None
9309
9415
  yield o
9310
9416
 
9311
- elif isinstance(o, self.AnyReadIo):
9417
+ elif isinstance(o, CoroHttpIo.AnyReadIo):
9312
9418
  i = check.isinstance((yield o), bytes)
9313
9419
 
9314
9420
  elif isinstance(o, self._Response):
@@ -9316,10 +9422,10 @@ class CoroHttpServer:
9316
9422
 
9317
9423
  r = self._preprocess_response(o)
9318
9424
  hb = self._build_response_head_bytes(r)
9319
- check.none((yield self.WriteIo(hb)))
9425
+ check.none((yield CoroHttpIo.WriteIo(hb)))
9320
9426
 
9321
9427
  for b in self._yield_response_data(r):
9322
- yield self.WriteIo(b)
9428
+ yield CoroHttpIo.WriteIo(b)
9323
9429
 
9324
9430
  o.close()
9325
9431
  if o.close_connection:
@@ -9347,7 +9453,7 @@ class CoroHttpServer:
9347
9453
  raise
9348
9454
 
9349
9455
  def _coro_handle_one(self) -> ta.Generator[
9350
- ta.Union[AnyLogIo, AnyReadIo, _Response],
9456
+ ta.Union[CoroHttpIo.AnyLogIo, CoroHttpIo.AnyReadIo, _Response],
9351
9457
  ta.Optional[bytes],
9352
9458
  None,
9353
9459
  ]:
@@ -9357,7 +9463,7 @@ class CoroHttpServer:
9357
9463
  sz = next(gen)
9358
9464
  while True:
9359
9465
  try:
9360
- line = check.isinstance((yield self.ReadLineIo(sz)), bytes)
9466
+ line = check.isinstance((yield CoroHttpIo.ReadLineIo(sz)), bytes)
9361
9467
  sz = gen.send(line)
9362
9468
  except StopIteration as e:
9363
9469
  parsed = e.value
@@ -9396,7 +9502,7 @@ class CoroHttpServer:
9396
9502
 
9397
9503
  request_data: ta.Optional[bytes]
9398
9504
  if (cl := parsed.headers.get('Content-Length')) is not None:
9399
- request_data = check.isinstance((yield self.ReadIo(int(cl))), bytes)
9505
+ request_data = check.isinstance((yield CoroHttpIo.ReadIo(int(cl))), bytes)
9400
9506
  else:
9401
9507
  request_data = None
9402
9508
 
@@ -11441,7 +11547,7 @@ class CoroHttpServerSocketHandler(SocketHandler_):
11441
11547
  server_factory: CoroHttpServerFactory,
11442
11548
  *,
11443
11549
  keep_alive: bool = False,
11444
- log_handler: ta.Optional[ta.Callable[[CoroHttpServer, CoroHttpServer.AnyLogIo], None]] = None,
11550
+ log_handler: ta.Optional[ta.Callable[[CoroHttpServer, CoroHttpIo.AnyLogIo], None]] = None,
11445
11551
  ) -> None:
11446
11552
  super().__init__()
11447
11553
 
@@ -11470,18 +11576,18 @@ class CoroHttpServerSocketHandler(SocketHandler_):
11470
11576
 
11471
11577
  o = next(gen)
11472
11578
  while True:
11473
- if isinstance(o, CoroHttpServer.AnyLogIo):
11579
+ if isinstance(o, CoroHttpIo.AnyLogIo):
11474
11580
  i = None
11475
11581
  if self._log_handler is not None:
11476
11582
  self._log_handler(server, o)
11477
11583
 
11478
- elif isinstance(o, CoroHttpServer.ReadIo):
11479
- i = fp.r.read(o.sz)
11584
+ elif isinstance(o, CoroHttpIo.ReadIo):
11585
+ i = fp.r.read(check.not_none(o.sz))
11480
11586
 
11481
- elif isinstance(o, CoroHttpServer.ReadLineIo):
11587
+ elif isinstance(o, CoroHttpIo.ReadLineIo):
11482
11588
  i = fp.r.readline(o.sz)
11483
11589
 
11484
- elif isinstance(o, CoroHttpServer.WriteIo):
11590
+ elif isinstance(o, CoroHttpIo.WriteIo):
11485
11591
  i = None
11486
11592
  fp.w.write(o.data)
11487
11593
  fp.w.flush()
omdev/scripts/interp.py CHANGED
@@ -686,6 +686,62 @@ def async_cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
686
686
  return _AsyncCachedNullary(fn)
687
687
 
688
688
 
689
+ ##
690
+
691
+
692
+ cached_property = functools.cached_property
693
+
694
+
695
+ class _cached_property: # noqa
696
+ """Backported to pick up https://github.com/python/cpython/commit/056dfc71dce15f81887f0bd6da09d6099d71f979 ."""
697
+
698
+ def __init__(self, func):
699
+ self.func = func
700
+ self.attrname = None # noqa
701
+ self.__doc__ = func.__doc__
702
+ self.__module__ = func.__module__
703
+
704
+ _NOT_FOUND = object()
705
+
706
+ def __set_name__(self, owner, name):
707
+ if self.attrname is None:
708
+ self.attrname = name # noqa
709
+ elif name != self.attrname:
710
+ raise TypeError(
711
+ f'Cannot assign the same cached_property to two different names ({self.attrname!r} and {name!r}).',
712
+ )
713
+
714
+ def __get__(self, instance, owner=None):
715
+ if instance is None:
716
+ return self
717
+ if self.attrname is None:
718
+ raise TypeError('Cannot use cached_property instance without calling __set_name__ on it.')
719
+
720
+ try:
721
+ cache = instance.__dict__
722
+ except AttributeError: # not all objects have __dict__ (e.g. class defines slots)
723
+ raise TypeError(
724
+ f"No '__dict__' attribute on {type(instance).__name__!r} instance to cache {self.attrname!r} property.",
725
+ ) from None
726
+
727
+ val = cache.get(self.attrname, self._NOT_FOUND)
728
+
729
+ if val is self._NOT_FOUND:
730
+ val = self.func(instance)
731
+ try:
732
+ cache[self.attrname] = val
733
+ except TypeError:
734
+ raise TypeError(
735
+ f"The '__dict__' attribute on {type(instance).__name__!r} instance does not support item "
736
+ f"assignment for caching {self.attrname!r} property.",
737
+ ) from None
738
+
739
+ return val
740
+
741
+
742
+ globals()['cached_property'] = _cached_property
743
+
744
+
689
745
  ########################################
690
746
  # ../../../omlish/lite/check.py
691
747
  """
File without changes
@@ -3,7 +3,7 @@
3
3
  # @omlish-lite
4
4
  # @omlish-script
5
5
  # @omlish-generated
6
- # @omlish-amalg-output ../../omlish/lite/inject.py
6
+ # @omlish-amalg-output ../../../omlish/lite/inject.py
7
7
  # @omlish-git-diff-omit
8
8
  # ruff: noqa: UP006 UP007 UP036 UP043 UP045
9
9
  import abc