ominfra 0.0.0.dev173__tar.gz → 0.0.0.dev174__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. {ominfra-0.0.0.dev173/ominfra.egg-info → ominfra-0.0.0.dev174}/PKG-INFO +3 -3
  2. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/scripts/journald2aws.py +46 -0
  3. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/scripts/manage.py +46 -0
  4. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/scripts/supervisor.py +46 -0
  5. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174/ominfra.egg-info}/PKG-INFO +3 -3
  6. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra.egg-info/requires.txt +2 -2
  7. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/pyproject.toml +3 -3
  8. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/LICENSE +0 -0
  9. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/MANIFEST.in +0 -0
  10. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/README.rst +0 -0
  11. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/.manifests.json +0 -0
  12. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/__about__.py +0 -0
  13. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/__init__.py +0 -0
  14. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/__init__.py +0 -0
  15. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/__init__.py +0 -0
  16. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/__main__.py +0 -0
  17. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/auth.py +0 -0
  18. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/cli.py +0 -0
  19. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/dataclasses.py +0 -0
  20. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
  21. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
  22. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
  23. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
  24. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/main.py +0 -0
  25. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
  26. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/logs.py +0 -0
  27. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/aws/metadata.py +0 -0
  28. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/gcp/__init__.py +0 -0
  29. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/clouds/gcp/auth.py +0 -0
  30. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/cmds.py +0 -0
  31. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/configs.py +0 -0
  32. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/journald/__init__.py +0 -0
  33. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/journald/fields.py +0 -0
  34. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/journald/genmessages.py +0 -0
  35. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/journald/messages.py +0 -0
  36. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/journald/tailer.py +0 -0
  37. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/__init__.py +0 -0
  38. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/__main__.py +0 -0
  39. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/bootstrap.py +0 -0
  40. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/bootstrap_.py +0 -0
  41. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/__init__.py +0 -0
  42. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/base.py +0 -0
  43. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/inject.py +0 -0
  44. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/local.py +0 -0
  45. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/marshal.py +0 -0
  46. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/ping.py +0 -0
  47. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/subprocess.py +0 -0
  48. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/commands/types.py +0 -0
  49. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/config.py +0 -0
  50. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/__init__.py +0 -0
  51. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/apps.py +0 -0
  52. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/commands.py +0 -0
  53. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/conf.py +0 -0
  54. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/config.py +0 -0
  55. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/deploy.py +0 -0
  56. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/git.py +0 -0
  57. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/inject.py +0 -0
  58. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/interp.py +0 -0
  59. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/__init__.py +0 -0
  60. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/inject.py +0 -0
  61. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/manager.py +0 -0
  62. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/owners.py +0 -0
  63. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/paths.py +0 -0
  64. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/paths/types.py +0 -0
  65. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/specs.py +0 -0
  66. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/tags.py +0 -0
  67. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/tmp.py +0 -0
  68. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/types.py +0 -0
  69. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/deploy/venvs.py +0 -0
  70. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/inject.py +0 -0
  71. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/main.py +0 -0
  72. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/marshal.py +0 -0
  73. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/__init__.py +0 -0
  74. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/_main.py +0 -0
  75. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/channel.py +0 -0
  76. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/config.py +0 -0
  77. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/connection.py +0 -0
  78. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/execution.py +0 -0
  79. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/inject.py +0 -0
  80. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/payload.py +0 -0
  81. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/remote/spawning.py +0 -0
  82. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/__init__.py +0 -0
  83. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/commands.py +0 -0
  84. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/config.py +0 -0
  85. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/inject.py +0 -0
  86. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/packages.py +0 -0
  87. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/system/platforms.py +0 -0
  88. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/__init__.py +0 -0
  89. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/bestpython.py +0 -0
  90. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/bestpython.sh +0 -0
  91. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/connection.py +0 -0
  92. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/inject.py +0 -0
  93. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/manage/targets/targets.py +0 -0
  94. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/pyremote.py +0 -0
  95. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/scripts/__init__.py +0 -0
  96. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/ssh.py +0 -0
  97. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/LICENSE.txt +0 -0
  98. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/__init__.py +0 -0
  99. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/__main__.py +0 -0
  100. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/configs.py +0 -0
  101. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/dispatchers.py +0 -0
  102. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/dispatchersimpl.py +0 -0
  103. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/events.py +0 -0
  104. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/exceptions.py +0 -0
  105. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/groups.py +0 -0
  106. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/groupsimpl.py +0 -0
  107. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/http.py +0 -0
  108. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/inject.py +0 -0
  109. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/io.py +0 -0
  110. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/main.py +0 -0
  111. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/pipes.py +0 -0
  112. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/privileges.py +0 -0
  113. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/process.py +0 -0
  114. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/processimpl.py +0 -0
  115. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/setup.py +0 -0
  116. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/setupimpl.py +0 -0
  117. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/signals.py +0 -0
  118. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/spawning.py +0 -0
  119. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/spawningimpl.py +0 -0
  120. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/states.py +0 -0
  121. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/supervisor.py +0 -0
  122. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/types.py +0 -0
  123. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/__init__.py +0 -0
  124. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/collections.py +0 -0
  125. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/diag.py +0 -0
  126. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/fds.py +0 -0
  127. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/fs.py +0 -0
  128. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/os.py +0 -0
  129. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/ostypes.py +0 -0
  130. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/signals.py +0 -0
  131. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/strings.py +0 -0
  132. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/supervisor/utils/users.py +0 -0
  133. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/tailscale/__init__.py +0 -0
  134. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/tailscale/api.py +0 -0
  135. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/tailscale/cli.py +0 -0
  136. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/threadworkers.py +0 -0
  137. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/tools/__init__.py +0 -0
  138. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra/tools/listresources.py +0 -0
  139. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra.egg-info/SOURCES.txt +0 -0
  140. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra.egg-info/dependency_links.txt +0 -0
  141. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra.egg-info/entry_points.txt +0 -0
  142. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/ominfra.egg-info/top_level.txt +0 -0
  143. {ominfra-0.0.0.dev173 → ominfra-0.0.0.dev174}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev173
3
+ Version: 0.0.0.dev174
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev173
16
- Requires-Dist: omlish==0.0.0.dev173
15
+ Requires-Dist: omdev==0.0.0.dev174
16
+ Requires-Dist: omlish==0.0.0.dev174
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -1450,6 +1450,9 @@ log = logging.getLogger(__name__)
1450
1450
  # ../../../../../omlish/lite/reflect.py
1451
1451
 
1452
1452
 
1453
+ ##
1454
+
1455
+
1453
1456
  _GENERIC_ALIAS_TYPES = (
1454
1457
  ta._GenericAlias, # type: ignore # noqa
1455
1458
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -1467,6 +1470,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
1467
1470
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
1468
1471
 
1469
1472
 
1473
+ ##
1474
+
1475
+
1470
1476
  def is_optional_alias(spec: ta.Any) -> bool:
1471
1477
  return (
1472
1478
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -1481,6 +1487,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
1481
1487
  return it
1482
1488
 
1483
1489
 
1490
+ ##
1491
+
1492
+
1484
1493
  def is_new_type(spec: ta.Any) -> bool:
1485
1494
  if isinstance(ta.NewType, type):
1486
1495
  return isinstance(spec, ta.NewType)
@@ -1493,6 +1502,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
1493
1502
  return spec.__supertype__
1494
1503
 
1495
1504
 
1505
+ ##
1506
+
1507
+
1508
+ def is_literal_type(spec: ta.Any) -> bool:
1509
+ if hasattr(ta, '_LiteralGenericAlias'):
1510
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
1511
+ else:
1512
+ return (
1513
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
1514
+ spec.__origin__ is ta.Literal
1515
+ )
1516
+
1517
+
1518
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
1519
+ return spec.__args__
1520
+
1521
+
1522
+ ##
1523
+
1524
+
1496
1525
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
1497
1526
  seen = set()
1498
1527
  todo = list(reversed(cls.__subclasses__()))
@@ -2600,6 +2629,18 @@ class OptionalObjMarshaler(ObjMarshaler):
2600
2629
  return self.item.unmarshal(o, ctx)
2601
2630
 
2602
2631
 
2632
+ @dc.dataclass(frozen=True)
2633
+ class LiteralObjMarshaler(ObjMarshaler):
2634
+ item: ObjMarshaler
2635
+ vs: frozenset
2636
+
2637
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2638
+ return self.item.marshal(check.in_(o, self.vs), ctx)
2639
+
2640
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2641
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
2642
+
2643
+
2603
2644
  @dc.dataclass(frozen=True)
2604
2645
  class MappingObjMarshaler(ObjMarshaler):
2605
2646
  ty: type
@@ -2811,6 +2852,11 @@ class ObjMarshalerManager:
2811
2852
  if is_new_type(ty):
2812
2853
  return rec(get_new_type_supertype(ty))
2813
2854
 
2855
+ if is_literal_type(ty):
2856
+ lvs = frozenset(get_literal_type_args(ty))
2857
+ lty = check.single(set(map(type, lvs)))
2858
+ return LiteralObjMarshaler(rec(lty), lvs)
2859
+
2814
2860
  if is_generic_alias(ty):
2815
2861
  try:
2816
2862
  mt = self._generic_mapping_types[ta.get_origin(ty)]
@@ -2667,6 +2667,9 @@ def pycharm_debug_preamble(prd: PycharmRemoteDebug) -> str:
2667
2667
  # ../../../omlish/lite/reflect.py
2668
2668
 
2669
2669
 
2670
+ ##
2671
+
2672
+
2670
2673
  _GENERIC_ALIAS_TYPES = (
2671
2674
  ta._GenericAlias, # type: ignore # noqa
2672
2675
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -2684,6 +2687,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
2684
2687
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
2685
2688
 
2686
2689
 
2690
+ ##
2691
+
2692
+
2687
2693
  def is_optional_alias(spec: ta.Any) -> bool:
2688
2694
  return (
2689
2695
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -2698,6 +2704,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
2698
2704
  return it
2699
2705
 
2700
2706
 
2707
+ ##
2708
+
2709
+
2701
2710
  def is_new_type(spec: ta.Any) -> bool:
2702
2711
  if isinstance(ta.NewType, type):
2703
2712
  return isinstance(spec, ta.NewType)
@@ -2710,6 +2719,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
2710
2719
  return spec.__supertype__
2711
2720
 
2712
2721
 
2722
+ ##
2723
+
2724
+
2725
+ def is_literal_type(spec: ta.Any) -> bool:
2726
+ if hasattr(ta, '_LiteralGenericAlias'):
2727
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
2728
+ else:
2729
+ return (
2730
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
2731
+ spec.__origin__ is ta.Literal
2732
+ )
2733
+
2734
+
2735
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
2736
+ return spec.__args__
2737
+
2738
+
2739
+ ##
2740
+
2741
+
2713
2742
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
2714
2743
  seen = set()
2715
2744
  todo = list(reversed(cls.__subclasses__()))
@@ -6049,6 +6078,18 @@ class OptionalObjMarshaler(ObjMarshaler):
6049
6078
  return self.item.unmarshal(o, ctx)
6050
6079
 
6051
6080
 
6081
+ @dc.dataclass(frozen=True)
6082
+ class LiteralObjMarshaler(ObjMarshaler):
6083
+ item: ObjMarshaler
6084
+ vs: frozenset
6085
+
6086
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
6087
+ return self.item.marshal(check.in_(o, self.vs), ctx)
6088
+
6089
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
6090
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
6091
+
6092
+
6052
6093
  @dc.dataclass(frozen=True)
6053
6094
  class MappingObjMarshaler(ObjMarshaler):
6054
6095
  ty: type
@@ -6260,6 +6301,11 @@ class ObjMarshalerManager:
6260
6301
  if is_new_type(ty):
6261
6302
  return rec(get_new_type_supertype(ty))
6262
6303
 
6304
+ if is_literal_type(ty):
6305
+ lvs = frozenset(get_literal_type_args(ty))
6306
+ lty = check.single(set(map(type, lvs)))
6307
+ return LiteralObjMarshaler(rec(lty), lvs)
6308
+
6263
6309
  if is_generic_alias(ty):
6264
6310
  try:
6265
6311
  mt = self._generic_mapping_types[ta.get_origin(ty)]
@@ -2259,6 +2259,9 @@ Maybe._empty = tuple.__new__(_Maybe, ()) # noqa
2259
2259
  # ../../../omlish/lite/reflect.py
2260
2260
 
2261
2261
 
2262
+ ##
2263
+
2264
+
2262
2265
  _GENERIC_ALIAS_TYPES = (
2263
2266
  ta._GenericAlias, # type: ignore # noqa
2264
2267
  *([ta._SpecialGenericAlias] if hasattr(ta, '_SpecialGenericAlias') else []), # noqa
@@ -2276,6 +2279,9 @@ is_union_alias = functools.partial(is_generic_alias, origin=ta.Union)
2276
2279
  is_callable_alias = functools.partial(is_generic_alias, origin=ta.Callable)
2277
2280
 
2278
2281
 
2282
+ ##
2283
+
2284
+
2279
2285
  def is_optional_alias(spec: ta.Any) -> bool:
2280
2286
  return (
2281
2287
  isinstance(spec, _GENERIC_ALIAS_TYPES) and # noqa
@@ -2290,6 +2296,9 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
2290
2296
  return it
2291
2297
 
2292
2298
 
2299
+ ##
2300
+
2301
+
2293
2302
  def is_new_type(spec: ta.Any) -> bool:
2294
2303
  if isinstance(ta.NewType, type):
2295
2304
  return isinstance(spec, ta.NewType)
@@ -2302,6 +2311,26 @@ def get_new_type_supertype(spec: ta.Any) -> ta.Any:
2302
2311
  return spec.__supertype__
2303
2312
 
2304
2313
 
2314
+ ##
2315
+
2316
+
2317
+ def is_literal_type(spec: ta.Any) -> bool:
2318
+ if hasattr(ta, '_LiteralGenericAlias'):
2319
+ return isinstance(spec, ta._LiteralGenericAlias) # noqa
2320
+ else:
2321
+ return (
2322
+ isinstance(spec, ta._GenericAlias) and # type: ignore # noqa
2323
+ spec.__origin__ is ta.Literal
2324
+ )
2325
+
2326
+
2327
+ def get_literal_type_args(spec: ta.Any) -> ta.Iterable[ta.Any]:
2328
+ return spec.__args__
2329
+
2330
+
2331
+ ##
2332
+
2333
+
2305
2334
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
2306
2335
  seen = set()
2307
2336
  todo = list(reversed(cls.__subclasses__()))
@@ -4991,6 +5020,18 @@ class OptionalObjMarshaler(ObjMarshaler):
4991
5020
  return self.item.unmarshal(o, ctx)
4992
5021
 
4993
5022
 
5023
+ @dc.dataclass(frozen=True)
5024
+ class LiteralObjMarshaler(ObjMarshaler):
5025
+ item: ObjMarshaler
5026
+ vs: frozenset
5027
+
5028
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
5029
+ return self.item.marshal(check.in_(o, self.vs), ctx)
5030
+
5031
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
5032
+ return check.in_(self.item.unmarshal(o, ctx), self.vs)
5033
+
5034
+
4994
5035
  @dc.dataclass(frozen=True)
4995
5036
  class MappingObjMarshaler(ObjMarshaler):
4996
5037
  ty: type
@@ -5202,6 +5243,11 @@ class ObjMarshalerManager:
5202
5243
  if is_new_type(ty):
5203
5244
  return rec(get_new_type_supertype(ty))
5204
5245
 
5246
+ if is_literal_type(ty):
5247
+ lvs = frozenset(get_literal_type_args(ty))
5248
+ lty = check.single(set(map(type, lvs)))
5249
+ return LiteralObjMarshaler(rec(lty), lvs)
5250
+
5205
5251
  if is_generic_alias(ty):
5206
5252
  try:
5207
5253
  mt = self._generic_mapping_types[ta.get_origin(ty)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev173
3
+ Version: 0.0.0.dev174
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev173
16
- Requires-Dist: omlish==0.0.0.dev173
15
+ Requires-Dist: omdev==0.0.0.dev174
16
+ Requires-Dist: omlish==0.0.0.dev174
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -1,5 +1,5 @@
1
- omdev==0.0.0.dev173
2
- omlish==0.0.0.dev173
1
+ omdev==0.0.0.dev174
2
+ omlish==0.0.0.dev174
3
3
 
4
4
  [all]
5
5
  paramiko~=3.5
@@ -12,7 +12,7 @@ authors = [
12
12
  urls = {source = 'https://github.com/wrmsr/omlish'}
13
13
  license = {text = 'BSD-3-Clause'}
14
14
  requires-python = '>=3.12'
15
- version = '0.0.0.dev173'
15
+ version = '0.0.0.dev174'
16
16
  classifiers = [
17
17
  'License :: OSI Approved :: BSD License',
18
18
  'Development Status :: 2 - Pre-Alpha',
@@ -22,8 +22,8 @@ classifiers = [
22
22
  ]
23
23
  description = 'ominfra'
24
24
  dependencies = [
25
- 'omdev == 0.0.0.dev173',
26
- 'omlish == 0.0.0.dev173',
25
+ 'omdev == 0.0.0.dev174',
26
+ 'omlish == 0.0.0.dev174',
27
27
  ]
28
28
 
29
29
  [project.optional-dependencies]
File without changes
File without changes