omlish 0.0.0.dev1__py3-none-any.whl → 0.0.0.dev3__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.

Potentially problematic release.


This version of omlish might be problematic. Click here for more details.

Files changed (147) hide show
  1. omlish/__about__.py +2 -3
  2. omlish/argparse.py +8 -8
  3. omlish/asyncs/__init__.py +2 -2
  4. omlish/asyncs/anyio.py +64 -1
  5. omlish/asyncs/asyncs.py +1 -3
  6. omlish/asyncs/futures.py +16 -15
  7. omlish/c3.py +5 -5
  8. omlish/check.py +8 -8
  9. omlish/collections/__init__.py +98 -63
  10. omlish/collections/_abc.py +2 -0
  11. omlish/collections/_io_abc.py +4 -2
  12. omlish/collections/cache/__init__.py +1 -1
  13. omlish/collections/cache/descriptor.py +12 -12
  14. omlish/collections/cache/impl.py +27 -20
  15. omlish/collections/cache/types.py +1 -1
  16. omlish/collections/coerce.py +44 -44
  17. omlish/collections/frozen.py +9 -9
  18. omlish/collections/identity.py +4 -5
  19. omlish/collections/mappings.py +5 -5
  20. omlish/collections/ordered.py +8 -8
  21. omlish/collections/skiplist.py +7 -7
  22. omlish/collections/sorted.py +4 -4
  23. omlish/collections/treap.py +42 -17
  24. omlish/collections/treapmap.py +59 -7
  25. omlish/collections/unmodifiable.py +25 -24
  26. omlish/collections/utils.py +1 -1
  27. omlish/configs/flattening.py +8 -7
  28. omlish/configs/props.py +3 -3
  29. omlish/dataclasses/__init__.py +1 -1
  30. omlish/dataclasses/impl/__init__.py +18 -0
  31. omlish/dataclasses/impl/api.py +15 -24
  32. omlish/dataclasses/impl/as_.py +4 -4
  33. omlish/dataclasses/impl/exceptions.py +1 -1
  34. omlish/dataclasses/impl/fields.py +8 -8
  35. omlish/dataclasses/impl/frozen.py +2 -2
  36. omlish/dataclasses/impl/init.py +6 -6
  37. omlish/dataclasses/impl/internals.py +16 -1
  38. omlish/dataclasses/impl/main.py +4 -4
  39. omlish/dataclasses/impl/metaclass.py +2 -2
  40. omlish/dataclasses/impl/metadata.py +1 -1
  41. omlish/dataclasses/impl/order.py +2 -2
  42. omlish/dataclasses/impl/params.py +4 -38
  43. omlish/dataclasses/impl/reflect.py +1 -7
  44. omlish/dataclasses/impl/replace.py +1 -1
  45. omlish/dataclasses/impl/repr.py +24 -6
  46. omlish/dataclasses/impl/simple.py +2 -2
  47. omlish/dataclasses/impl/slots.py +2 -2
  48. omlish/dataclasses/impl/utils.py +7 -7
  49. omlish/defs.py +13 -17
  50. omlish/diag/procfs.py +334 -0
  51. omlish/diag/ps.py +47 -0
  52. omlish/{replserver → diag/replserver}/console.py +26 -28
  53. omlish/{replserver → diag/replserver}/server.py +12 -12
  54. omlish/dispatch/dispatch.py +14 -16
  55. omlish/dispatch/functions.py +1 -1
  56. omlish/dispatch/methods.py +6 -7
  57. omlish/docker.py +8 -6
  58. omlish/dynamic.py +13 -13
  59. omlish/fnpairs.py +311 -0
  60. omlish/graphs/dot/items.py +1 -1
  61. omlish/graphs/trees.py +25 -31
  62. omlish/inject/__init__.py +7 -7
  63. omlish/inject/elements.py +2 -2
  64. omlish/inject/exceptions.py +8 -8
  65. omlish/inject/impl/elements.py +4 -4
  66. omlish/inject/impl/injector.py +6 -6
  67. omlish/inject/impl/inspect.py +3 -3
  68. omlish/inject/impl/scopes.py +9 -9
  69. omlish/inject/injector.py +1 -1
  70. omlish/inject/providers.py +2 -2
  71. omlish/inject/proxy.py +5 -5
  72. omlish/iterators.py +62 -26
  73. omlish/json.py +7 -6
  74. omlish/lang/__init__.py +172 -112
  75. omlish/lang/cached.py +15 -10
  76. omlish/lang/classes/__init__.py +35 -24
  77. omlish/lang/classes/abstract.py +3 -3
  78. omlish/lang/classes/restrict.py +14 -14
  79. omlish/lang/classes/simple.py +2 -2
  80. omlish/lang/classes/virtual.py +5 -5
  81. omlish/lang/clsdct.py +2 -2
  82. omlish/lang/cmp.py +2 -2
  83. omlish/lang/contextmanagers.py +31 -25
  84. omlish/lang/datetimes.py +1 -1
  85. omlish/lang/descriptors.py +51 -6
  86. omlish/lang/exceptions.py +2 -0
  87. omlish/lang/functions.py +101 -35
  88. omlish/lang/imports.py +25 -30
  89. omlish/lang/iterables.py +2 -2
  90. omlish/lang/maybes.py +2 -1
  91. omlish/lang/objects.py +17 -11
  92. omlish/lang/resolving.py +1 -1
  93. omlish/lang/strings.py +1 -1
  94. omlish/lang/timeouts.py +53 -0
  95. omlish/lang/typing.py +5 -5
  96. omlish/libc.py +15 -11
  97. omlish/logs/_abc.py +5 -1
  98. omlish/logs/filters.py +2 -0
  99. omlish/logs/formatters.py +6 -2
  100. omlish/logs/utils.py +1 -1
  101. omlish/marshal/base.py +9 -9
  102. omlish/marshal/dataclasses.py +2 -2
  103. omlish/marshal/enums.py +2 -2
  104. omlish/marshal/exceptions.py +1 -1
  105. omlish/marshal/factories.py +10 -10
  106. omlish/marshal/global_.py +10 -4
  107. omlish/marshal/iterables.py +2 -2
  108. omlish/marshal/mappings.py +2 -2
  109. omlish/marshal/objects.py +1 -2
  110. omlish/marshal/optionals.py +4 -4
  111. omlish/marshal/polymorphism.py +4 -4
  112. omlish/marshal/registries.py +3 -3
  113. omlish/marshal/standard.py +6 -6
  114. omlish/marshal/utils.py +3 -3
  115. omlish/marshal/values.py +1 -1
  116. omlish/math.py +9 -9
  117. omlish/os.py +13 -4
  118. omlish/reflect.py +5 -15
  119. omlish/sql/__init__.py +0 -0
  120. omlish/sql/_abc.py +65 -0
  121. omlish/sql/dbs.py +90 -0
  122. omlish/stats.py +7 -8
  123. omlish/term.py +1 -1
  124. omlish/testing/pydevd.py +30 -12
  125. omlish/testing/pytest/inject/__init__.py +7 -0
  126. omlish/testing/pytest/inject/harness.py +24 -2
  127. omlish/testing/pytest/plugins/__init__.py +1 -1
  128. omlish/testing/pytest/plugins/pydevd.py +12 -0
  129. omlish/testing/pytest/plugins/switches.py +3 -3
  130. omlish/testing/testing.py +5 -5
  131. omlish/text/delimit.py +3 -6
  132. omlish/text/parts.py +3 -3
  133. omlish-0.0.0.dev3.dist-info/METADATA +31 -0
  134. omlish-0.0.0.dev3.dist-info/RECORD +191 -0
  135. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev3.dist-info}/WHEEL +1 -1
  136. omlish/lang/classes/test/test_abstract.py +0 -89
  137. omlish/lang/classes/test/test_restrict.py +0 -71
  138. omlish/lang/classes/test/test_simple.py +0 -58
  139. omlish/lang/classes/test/test_virtual.py +0 -72
  140. omlish/testing/pytest/plugins/pycharm.py +0 -54
  141. omlish-0.0.0.dev1.dist-info/METADATA +0 -17
  142. omlish-0.0.0.dev1.dist-info/RECORD +0 -187
  143. /omlish/{lang/classes/test → diag}/__init__.py +0 -0
  144. /omlish/{replserver → diag/replserver}/__init__.py +0 -0
  145. /omlish/{replserver → diag/replserver}/__main__.py +0 -0
  146. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev3.dist-info}/LICENSE +0 -0
  147. {omlish-0.0.0.dev1.dist-info → omlish-0.0.0.dev3.dist-info}/top_level.txt +0 -0
omlish/lang/__init__.py CHANGED
@@ -1,112 +1,172 @@
1
- from .cached import cached_function # noqa
2
- from .cached import cached_property # noqa
3
- from .classes import Abstract # noqa
4
- from .classes import Callable # noqa
5
- from .classes import Descriptor # noqa
6
- from .classes import Final # noqa
7
- from .classes import FinalException # noqa
8
- from .classes import LazySingleton # noqa
9
- from .classes import Marker # noqa
10
- from .classes import Namespace # noqa
11
- from .classes import NoBool # noqa
12
- from .classes import NotInstantiable # noqa
13
- from .classes import NotPicklable # noqa
14
- from .classes import PackageSealed # noqa
15
- from .classes import Picklable # noqa
16
- from .classes import Sealed # noqa
17
- from .classes import SealedException # noqa
18
- from .classes import SimpleMetaDict # noqa
19
- from .classes import Singleton # noqa
20
- from .classes import Virtual # noqa
21
- from .classes import is_abstract # noqa
22
- from .classes import is_abstract_class # noqa
23
- from .classes import is_abstract_method # noqa
24
- from .classes import make_abstract # noqa
25
- from .classes import no_bool # noqa
26
- from .classes import virtual_check # noqa
27
- from .clsdct import ClassDctFn # noqa
28
- from .clsdct import cls_dct_fn # noqa
29
- from .clsdct import get_caller_cls_dct # noqa
30
- from .clsdct import is_possibly_cls_dct # noqa
31
- from .cmp import Infinity # noqa
32
- from .cmp import InfinityType # noqa
33
- from .cmp import NegativeInfinity # noqa
34
- from .cmp import NegativeInfinityType # noqa
35
- from .cmp import cmp # noqa
36
- from .contextmanagers import ContextManaged # noqa
37
- from .contextmanagers import ContextWrapped # noqa
38
- from .contextmanagers import DefaultLockable # noqa
39
- from .contextmanagers import ExitStacked # noqa
40
- from .contextmanagers import Lockable # noqa
41
- from .contextmanagers import NOP_CONTEXT_MANAGED # noqa
42
- from .contextmanagers import NOP_CONTEXT_MANAGER # noqa
43
- from .contextmanagers import NopContextManaged # noqa
44
- from .contextmanagers import NopContextManager # noqa
45
- from .contextmanagers import a_defer # noqa
46
- from .contextmanagers import attr_setting # noqa
47
- from .contextmanagers import breakpoint_on_exception # noqa
48
- from .contextmanagers import context_var_setting # noqa
49
- from .contextmanagers import context_wrapped # noqa
50
- from .contextmanagers import default_lock # noqa
51
- from .contextmanagers import defer # noqa
52
- from .contextmanagers import disposing # noqa
53
- from .contextmanagers import maybe_managing # noqa
54
- from .datetimes import months_ago # noqa
55
- from .datetimes import parse_date # noqa
56
- from .datetimes import parse_timedelta # noqa
57
- from .datetimes import to_seconds # noqa
58
- from .descriptors import AccessForbiddenException # noqa
59
- from .descriptors import access_forbidden # noqa
60
- from .descriptors import is_method_descriptor # noqa
61
- from .descriptors import unwrap_method_descriptors # noqa
62
- from .functions import VoidException # noqa
63
- from .functions import constant # noqa
64
- from .functions import identity # noqa
65
- from .functions import is_lambda # noqa
66
- from .functions import is_none # noqa
67
- from .functions import is_not_none # noqa
68
- from .functions import maybe_call # noqa
69
- from .functions import raise_ # noqa
70
- from .functions import recurse # noqa
71
- from .functions import ticking_timeout # noqa
72
- from .functions import try_ # noqa
73
- from .functions import unwrap_func # noqa
74
- from .functions import unwrap_func_with_partials # noqa
75
- from .functions import void # noqa
76
- from .imports import import_all # noqa
77
- from .imports import import_module # noqa
78
- from .imports import import_module_attr # noqa
79
- from .imports import lazy_import # noqa
80
- from .imports import proxy_import # noqa
81
- from .imports import try_import # noqa
82
- from .imports import yield_import_all # noqa
83
- from .imports import yield_importable # noqa
84
- from .iterables import BUILTIN_SCALAR_ITERABLE_TYPES # noqa
85
- from .iterables import asrange # noqa
86
- from .iterables import exhaust # noqa
87
- from .iterables import ilen # noqa
88
- from .iterables import peek # noqa
89
- from .iterables import prodrange # noqa
90
- from .iterables import take # noqa
91
- from .maybes import Maybe # noqa
92
- from .maybes import empty # noqa
93
- from .maybes import just # noqa
94
- from .maybes import maybe # noqa
95
- from .objects import SimpleProxy # noqa
96
- from .objects import arg_repr # noqa
97
- from .objects import attr_repr # noqa
98
- from .objects import new_type # noqa
99
- from .objects import super_meta # noqa
100
- from .strings import camel_case # noqa
101
- from .strings import indent_lines # noqa
102
- from .strings import is_dunder # noqa
103
- from .strings import is_ident # noqa
104
- from .strings import is_ident_cont # noqa
105
- from .strings import is_ident_start # noqa
106
- from .strings import is_sunder # noqa
107
- from .strings import prefix_lines # noqa
108
- from .strings import snake_case # noqa
109
- from .typing import BytesLike # noqa
110
- from .typing import protocol_check # noqa
111
- from .typing import typed_lambda # noqa
112
- from .typing import typed_partial # noqa
1
+ from .cached import ( # noqa
2
+ cached_function,
3
+ cached_property,
4
+ )
5
+
6
+ from .classes import ( # noqa
7
+ Abstract,
8
+ Callable,
9
+ Descriptor,
10
+ Final,
11
+ FinalError,
12
+ LazySingleton,
13
+ Marker,
14
+ Namespace,
15
+ NoBool,
16
+ NotInstantiable,
17
+ NotPicklable,
18
+ PackageSealed,
19
+ Picklable,
20
+ Sealed,
21
+ SealedError,
22
+ SimpleMetaDict,
23
+ Singleton,
24
+ Virtual,
25
+ is_abstract,
26
+ is_abstract_class,
27
+ is_abstract_method,
28
+ make_abstract,
29
+ no_bool,
30
+ virtual_check,
31
+ )
32
+
33
+ from .clsdct import ( # noqa
34
+ ClassDctFn,
35
+ cls_dct_fn,
36
+ get_caller_cls_dct,
37
+ is_possibly_cls_dct,
38
+ )
39
+
40
+ from .cmp import ( # noqa
41
+ Infinity,
42
+ InfinityType,
43
+ NegativeInfinity,
44
+ NegativeInfinityType,
45
+ cmp,
46
+ )
47
+
48
+ from .contextmanagers import ( # noqa
49
+ ContextManaged,
50
+ ContextWrapped,
51
+ DefaultLockable,
52
+ ExitStacked,
53
+ Lockable,
54
+ NOP_CONTEXT_MANAGED,
55
+ NOP_CONTEXT_MANAGER,
56
+ NopContextManaged,
57
+ NopContextManager,
58
+ a_defer,
59
+ attr_setting,
60
+ breakpoint_on_exception,
61
+ context_var_setting,
62
+ context_wrapped,
63
+ default_lock,
64
+ defer,
65
+ disposing,
66
+ maybe_managing,
67
+ )
68
+
69
+ from .datetimes import ( # noqa
70
+ months_ago,
71
+ parse_date,
72
+ parse_timedelta,
73
+ to_seconds,
74
+ )
75
+
76
+ from .descriptors import ( # noqa
77
+ AccessForbiddenError,
78
+ access_forbidden,
79
+ attr_property,
80
+ classonly,
81
+ is_method_descriptor,
82
+ item_property,
83
+ unwrap_method_descriptors,
84
+ )
85
+
86
+ from .exceptions import ( # noqa
87
+ Unreachable,
88
+ )
89
+
90
+ from .functions import ( # noqa
91
+ Args,
92
+ VoidError,
93
+ constant,
94
+ finally_,
95
+ identity,
96
+ is_lambda,
97
+ is_none,
98
+ is_not_none,
99
+ maybe_call,
100
+ periodically,
101
+ raise_,
102
+ raising,
103
+ recurse,
104
+ try_,
105
+ unwrap_func,
106
+ unwrap_func_with_partials,
107
+ void,
108
+ )
109
+
110
+ from .imports import ( # noqa
111
+ import_all,
112
+ import_module,
113
+ import_module_attr,
114
+ lazy_import,
115
+ proxy_import,
116
+ try_import,
117
+ yield_import_all,
118
+ yield_importable,
119
+ )
120
+
121
+ from .iterables import ( # noqa
122
+ BUILTIN_SCALAR_ITERABLE_TYPES,
123
+ asrange,
124
+ exhaust,
125
+ ilen,
126
+ peek,
127
+ prodrange,
128
+ take,
129
+ )
130
+
131
+ from .maybes import ( # noqa
132
+ Maybe,
133
+ empty,
134
+ just,
135
+ maybe,
136
+ )
137
+
138
+ from .objects import ( # noqa
139
+ SimpleProxy,
140
+ arg_repr,
141
+ attr_repr,
142
+ new_type,
143
+ opt_repr,
144
+ super_meta,
145
+ )
146
+
147
+ from .strings import ( # noqa
148
+ camel_case,
149
+ indent_lines,
150
+ is_dunder,
151
+ is_ident,
152
+ is_ident_cont,
153
+ is_ident_start,
154
+ is_sunder,
155
+ prefix_lines,
156
+ snake_case,
157
+ )
158
+
159
+ from .timeouts import ( # noqa
160
+ DeadlineTimeout,
161
+ InfiniteTimeout,
162
+ Timeout,
163
+ TimeoutLike,
164
+ timeout,
165
+ )
166
+
167
+ from .typing import ( # noqa
168
+ BytesLike,
169
+ protocol_check,
170
+ typed_lambda,
171
+ typed_partial,
172
+ )
omlish/lang/cached.py CHANGED
@@ -105,11 +105,11 @@ class _CachedFunction(ta.Generic[T]):
105
105
  opts: Opts = Opts(),
106
106
  keyer: ta.Callable[..., tuple] | None = None,
107
107
  values: ta.MutableMapping | None = None,
108
- value_fn: ta.Optional[ta.Callable[P, T]] = None,
108
+ value_fn: ta.Callable[P, T] | None = None,
109
109
  ) -> None:
110
110
  super().__init__()
111
111
 
112
- self._fn = fn
112
+ self._fn = (fn,)
113
113
  self._opts = opts
114
114
  self._keyer = keyer if keyer is not None else _make_cache_keyer(fn, simple=opts.simple_key)
115
115
 
@@ -118,6 +118,14 @@ class _CachedFunction(ta.Generic[T]):
118
118
  self._value_fn = value_fn if value_fn is not None else fn
119
119
  functools.update_wrapper(self, fn)
120
120
 
121
+ @property
122
+ def _fn(self):
123
+ return self.__fn
124
+
125
+ @_fn.setter
126
+ def _fn(self, x):
127
+ self.__fn = x
128
+
121
129
  def reset(self) -> None:
122
130
  self._values = {}
123
131
 
@@ -157,8 +165,8 @@ class _CachedFunctionDescriptor(_CachedFunction[T]):
157
165
  *,
158
166
  instance: ta.Any = None,
159
167
  owner: ta.Any = None,
160
- name: ta.Optional[str] = None,
161
- **kwargs
168
+ name: str | None = None,
169
+ **kwargs,
162
170
  ) -> None:
163
171
  super().__init__(fn, **kwargs)
164
172
 
@@ -173,7 +181,7 @@ class _CachedFunctionDescriptor(_CachedFunction[T]):
173
181
  if owner is self._owner and (instance is self._instance or scope is classmethod):
174
182
  return self
175
183
 
176
- fn = self._fn
184
+ fn, = self._fn
177
185
  name = self._name
178
186
  bound_fn = fn.__get__(instance, owner)
179
187
  if self._bound_keyer is None:
@@ -199,7 +207,7 @@ class _CachedFunctionDescriptor(_CachedFunction[T]):
199
207
  return bound
200
208
 
201
209
 
202
- def cached_function(fn=None, **kwargs):
210
+ def cached_function(fn=None, **kwargs): # noqa
203
211
  if fn is None:
204
212
  return functools.partial(cached_function, **kwargs)
205
213
  opts = _CachedFunction.Opts(**kwargs)
@@ -209,9 +217,6 @@ def cached_function(fn=None, **kwargs):
209
217
  return _CachedFunctionDescriptor(fn, scope, opts=opts)
210
218
 
211
219
 
212
- cached_function = cached_function
213
-
214
-
215
220
  ##
216
221
 
217
222
 
@@ -261,7 +266,7 @@ class _CachedProperty:
261
266
  raise TypeError(self._name)
262
267
 
263
268
 
264
- def cached_property(fn=None, **kwargs):
269
+ def cached_property(fn=None, **kwargs): # noqa
265
270
  if fn is None:
266
271
  return functools.partial(cached_property, **kwargs)
267
272
  return _CachedProperty(fn, **kwargs)
@@ -1,24 +1,35 @@
1
- from .abstract import Abstract # noqa
2
- from .abstract import is_abstract # noqa
3
- from .abstract import is_abstract_class # noqa
4
- from .abstract import is_abstract_method # noqa
5
- from .abstract import make_abstract # noqa
6
- from .restrict import Final # noqa
7
- from .restrict import FinalException # noqa
8
- from .restrict import NoBool # noqa
9
- from .restrict import NotInstantiable # noqa
10
- from .restrict import NotPicklable # noqa
11
- from .restrict import PackageSealed # noqa
12
- from .restrict import Sealed # noqa
13
- from .restrict import SealedException # noqa
14
- from .restrict import no_bool # noqa
15
- from .simple import LazySingleton # noqa
16
- from .simple import Marker # noqa
17
- from .simple import Namespace # noqa
18
- from .simple import SimpleMetaDict # noqa
19
- from .simple import Singleton # noqa
20
- from .virtual import Callable # noqa
21
- from .virtual import Descriptor # noqa
22
- from .virtual import Picklable # noqa
23
- from .virtual import Virtual # noqa
24
- from .virtual import virtual_check # noqa
1
+ from .abstract import ( # noqa
2
+ Abstract,
3
+ is_abstract,
4
+ is_abstract_class,
5
+ is_abstract_method,
6
+ make_abstract,
7
+ )
8
+
9
+ from .restrict import ( # noqa
10
+ Final,
11
+ FinalError,
12
+ NoBool,
13
+ NotInstantiable,
14
+ NotPicklable,
15
+ PackageSealed,
16
+ Sealed,
17
+ SealedError,
18
+ no_bool,
19
+ )
20
+
21
+ from .simple import ( # noqa
22
+ LazySingleton,
23
+ Marker,
24
+ Namespace,
25
+ SimpleMetaDict,
26
+ Singleton,
27
+ )
28
+
29
+ from .virtual import ( # noqa
30
+ Callable,
31
+ Descriptor,
32
+ Picklable,
33
+ Virtual,
34
+ virtual_check,
35
+ )
@@ -23,7 +23,7 @@ def make_abstract(obj: T) -> T:
23
23
  return obj
24
24
 
25
25
 
26
- class Abstract(abc.ABC):
26
+ class Abstract(abc.ABC): # noqa
27
27
  __slots__ = ()
28
28
 
29
29
  def __forceabstract__(self):
@@ -31,7 +31,7 @@ class Abstract(abc.ABC):
31
31
 
32
32
  setattr(__forceabstract__, '__isabstractmethod__', True)
33
33
 
34
- def __init_subclass__(cls, **kwargs) -> None:
34
+ def __init_subclass__(cls, **kwargs: ta.Any) -> None:
35
35
  if Abstract in cls.__bases__:
36
36
  cls.__forceabstract__ = Abstract.__forceabstract__ # type: ignore
37
37
  else:
@@ -48,7 +48,7 @@ class Abstract(abc.ABC):
48
48
  if ams:
49
49
  raise TypeError(
50
50
  f'Cannot subclass abstract class {cls.__name__} with abstract methods'
51
- f'{", ".join(map(str, sorted(ams)))}'
51
+ f'{", ".join(map(str, sorted(ams)))}',
52
52
  )
53
53
 
54
54
 
@@ -8,9 +8,9 @@ from .abstract import is_abstract
8
8
  ##
9
9
 
10
10
 
11
- class FinalException(TypeError):
11
+ class FinalError(TypeError):
12
12
 
13
- def __init__(self, _type: ta.Type) -> None:
13
+ def __init__(self, _type: type) -> None:
14
14
  super().__init__()
15
15
 
16
16
  self._type = _type
@@ -22,17 +22,17 @@ class FinalException(TypeError):
22
22
  class Final(Abstract):
23
23
  __slots__ = ()
24
24
 
25
- def __init_subclass__(cls, **kwargs) -> None:
25
+ def __init_subclass__(cls, **kwargs: ta.Any) -> None:
26
26
  super().__init_subclass__(**kwargs)
27
27
 
28
28
  abstracts: set[ta.Any] = set()
29
29
  for base in cls.__bases__:
30
30
  if base is Abstract:
31
- raise FinalException(base)
31
+ raise FinalError(base)
32
32
  elif base is Final:
33
33
  continue
34
34
  elif Final in base.__mro__:
35
- raise FinalException(base)
35
+ raise FinalError(base)
36
36
  else:
37
37
  abstracts.update(getattr(base, '__abstractmethods__', []))
38
38
 
@@ -40,15 +40,15 @@ class Final(Abstract):
40
40
  try:
41
41
  v = cls.__dict__[a]
42
42
  except KeyError:
43
- raise FinalException(a)
43
+ raise FinalError(a) from None
44
44
  if is_abstract(v):
45
- raise FinalException(a)
45
+ raise FinalError(a)
46
46
 
47
47
 
48
48
  ##
49
49
 
50
50
 
51
- class SealedException(TypeError):
51
+ class SealedError(TypeError):
52
52
 
53
53
  def __init__(self, _type) -> None:
54
54
  super().__init__()
@@ -62,24 +62,24 @@ class SealedException(TypeError):
62
62
  class Sealed:
63
63
  __slots__ = ()
64
64
 
65
- def __init_subclass__(cls, **kwargs) -> None:
65
+ def __init_subclass__(cls, **kwargs: ta.Any) -> None:
66
66
  for base in cls.__bases__:
67
67
  if base is not Abstract:
68
68
  if Sealed in base.__bases__:
69
69
  if cls.__module__ != base.__module__:
70
- raise SealedException(base)
70
+ raise SealedError(base)
71
71
  super().__init_subclass__(**kwargs)
72
72
 
73
73
 
74
74
  class PackageSealed:
75
75
  __slots__ = ()
76
76
 
77
- def __init_subclass__(cls, **kwargs) -> None:
77
+ def __init_subclass__(cls, **kwargs: ta.Any) -> None:
78
78
  for base in cls.__bases__:
79
79
  if base is not Abstract:
80
80
  if PackageSealed in base.__bases__:
81
81
  if cls.__module__.split('.')[:-1] != base.__module__.split('.')[:-1]:
82
- raise SealedException(base)
82
+ raise SealedError(base)
83
83
  super().__init_subclass__(**kwargs)
84
84
 
85
85
 
@@ -89,7 +89,7 @@ class PackageSealed:
89
89
  class NotInstantiable(Abstract):
90
90
  __slots__ = ()
91
91
 
92
- def __new__(cls, *args, **kwargs) -> ta.NoReturn:
92
+ def __new__(cls, *args: ta.Any, **kwargs: ta.Any) -> ta.NoReturn: # noqa
93
93
  raise TypeError
94
94
 
95
95
 
@@ -133,5 +133,5 @@ class _NoBoolDescriptor:
133
133
  return self._fn(*args, **kwargs)
134
134
 
135
135
 
136
- def no_bool(fn):
136
+ def no_bool(fn): # noqa
137
137
  return _NoBoolDescriptor(fn)
@@ -26,7 +26,7 @@ Namespace: type = _Namespace() # type: ignore
26
26
  ##
27
27
 
28
28
 
29
- _MARKER_NAMESPACE_KEYS: ta.Optional[set[str]] = None
29
+ _MARKER_NAMESPACE_KEYS: set[str] | None = None
30
30
 
31
31
 
32
32
  class _MarkerMeta(abc.ABCMeta):
@@ -100,7 +100,7 @@ class Singleton:
100
100
  def __new__(cls):
101
101
  return cls.__dict__[_SINGLETON_INSTANCE_ATTR]
102
102
 
103
- def __init_subclass__(cls, **kwargs):
103
+ def __init_subclass__(cls, **kwargs: ta.Any) -> None:
104
104
  super().__init_subclass__(**kwargs)
105
105
  _set_singleton_instance(super().__new__(cls)) # noqa
106
106
 
@@ -15,10 +15,10 @@ Ty = ta.TypeVar('Ty', bound=type)
15
15
 
16
16
 
17
17
  def _make_not_instantiable():
18
- def __new__(cls, *args, **kwargs):
18
+ def __new__(cls, *args, **kwargs): # noqa
19
19
  raise TypeError(cls)
20
20
 
21
- def __init__(self, *args, **kwargs):
21
+ def __init__(self, *args, **kwargs): # noqa
22
22
  raise TypeError(self)
23
23
 
24
24
  return {
@@ -49,7 +49,7 @@ class _VirtualMeta(abc.ABCMeta):
49
49
  reqset -= set(mro_cls.__dict__)
50
50
  return reqset
51
51
 
52
- def __subclasshook__(cls, subclass):
52
+ def __subclasshook__(cls, subclass): # noqa
53
53
  if cls is not kls:
54
54
  return super(kls, cls).__subclasshook__(subclass) # type: ignore
55
55
  if get_missing_reqs(subclass):
@@ -117,11 +117,11 @@ class Callable(NotInstantiable, Final, ta.Generic[T]):
117
117
  raise TypeError
118
118
 
119
119
  @classmethod
120
- def __instancecheck__(cls, instance):
120
+ def __instancecheck__(cls, instance: object) -> bool:
121
121
  return callable(instance)
122
122
 
123
123
  @classmethod
124
- def __subclasscheck__(cls, subclass):
124
+ def __subclasscheck__(cls, subclass: type) -> bool:
125
125
  if not hasattr(subclass, '__call__'):
126
126
  return False
127
127
  call = subclass.__call__
omlish/lang/clsdct.py CHANGED
@@ -37,7 +37,7 @@ def get_caller_cls_dct(offset: int = 0) -> ta.MutableMapping[str, ta.Any]:
37
37
 
38
38
  class ClassDctFn:
39
39
 
40
- def __init__(self, fn: ta.Callable, offset: ta.Optional[int] = None, *, wrap=True) -> None:
40
+ def __init__(self, fn: ta.Callable, offset: int | None = None, *, wrap=True) -> None:
41
41
  super().__init__()
42
42
 
43
43
  self._fn = fn
@@ -60,7 +60,7 @@ class ClassDctFn:
60
60
  return self._fn(cls_dct, *args, **kwargs)
61
61
 
62
62
 
63
- def cls_dct_fn(offset=1, *, wrap=True):
63
+ def cls_dct_fn(offset=1, *, wrap=True): # noqa
64
64
  def outer(fn):
65
65
  return ClassDctFn(fn, offset, wrap=wrap)
66
66
 
omlish/lang/cmp.py CHANGED
@@ -18,7 +18,7 @@ class InfinityType:
18
18
  def __le__(self, other: ta.Any) -> bool:
19
19
  return False
20
20
 
21
- def __eq__(self, other: ta.Any) -> bool:
21
+ def __eq__(self, other: object) -> bool:
22
22
  return isinstance(other, self.__class__)
23
23
 
24
24
  def __gt__(self, other: ta.Any) -> bool:
@@ -47,7 +47,7 @@ class NegativeInfinityType:
47
47
  def __le__(self, other: ta.Any) -> bool:
48
48
  return True
49
49
 
50
- def __eq__(self, other: ta.Any) -> bool:
50
+ def __eq__(self, other: object) -> bool:
51
51
  return isinstance(other, self.__class__)
52
52
 
53
53
  def __gt__(self, other: ta.Any) -> bool: