jetpytools 1.2.7__tar.gz → 1.3.0__tar.gz

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 jetpytools might be problematic. Click here for more details.

Files changed (39) hide show
  1. {jetpytools-1.2.7 → jetpytools-1.3.0}/PKG-INFO +5 -2
  2. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/_metadata.py +1 -1
  3. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/enums/base.py +1 -5
  4. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/builtins.py +7 -2
  5. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/utils.py +45 -56
  6. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools.egg-info/PKG-INFO +5 -2
  7. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools.egg-info/SOURCES.txt +1 -0
  8. jetpytools-1.3.0/jetpytools.egg-info/requires.txt +1 -0
  9. {jetpytools-1.2.7 → jetpytools-1.3.0}/setup.py +1 -0
  10. {jetpytools-1.2.7 → jetpytools-1.3.0}/LICENSE +0 -0
  11. {jetpytools-1.2.7 → jetpytools-1.3.0}/README.md +0 -0
  12. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/__init__.py +0 -0
  13. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/enums/__init__.py +0 -0
  14. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/enums/other.py +0 -0
  15. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/__init__.py +0 -0
  16. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/base.py +0 -0
  17. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/enum.py +0 -0
  18. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/file.py +0 -0
  19. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/generic.py +0 -0
  20. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/exceptions/module.py +0 -0
  21. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/functions/__init__.py +0 -0
  22. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/functions/funcs.py +0 -0
  23. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/functions/normalize.py +0 -0
  24. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/functions/other.py +0 -0
  25. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/py.typed +0 -0
  26. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/__init__.py +0 -0
  27. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/check.py +0 -0
  28. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/file.py +0 -0
  29. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/funcs.py +0 -0
  30. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/generic.py +0 -0
  31. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/types/supports.py +0 -0
  32. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/utils/__init__.py +0 -0
  33. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/utils/file.py +0 -0
  34. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/utils/funcs.py +0 -0
  35. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/utils/math.py +0 -0
  36. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools/utils/ranges.py +0 -0
  37. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools.egg-info/dependency_links.txt +0 -0
  38. {jetpytools-1.2.7 → jetpytools-1.3.0}/jetpytools.egg-info/top_level.txt +0 -0
  39. {jetpytools-1.2.7 → jetpytools-1.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 1.2.7
3
+ Version: 1.3.0
4
4
  Summary: Collection of stuff that's useful in general python programming
5
5
  Author: Jaded Encoding Thaumaturgy
6
6
  Author-email: jaded.encoding.thaumaturgy@gmail.com
@@ -18,14 +18,17 @@ Classifier: Typing :: Typed
18
18
  Requires-Python: >=3.10
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Requires-Dist: typing_extensions>=4.12.2
21
22
  Dynamic: author
22
23
  Dynamic: author-email
23
24
  Dynamic: classifier
24
25
  Dynamic: description
25
26
  Dynamic: description-content-type
27
+ Dynamic: license-file
26
28
  Dynamic: maintainer
27
29
  Dynamic: maintainer-email
28
30
  Dynamic: project-url
31
+ Dynamic: requires-dist
29
32
  Dynamic: requires-python
30
33
  Dynamic: summary
31
34
 
@@ -1,6 +1,6 @@
1
1
  """Collection of stuff that's useful in general python programming"""
2
2
 
3
- __version__ = '1.2.7'
3
+ __version__ = '1.3.0'
4
4
 
5
5
  __author_name__, __author_email__ = 'Jaded Encoding Thaumaturgy', 'jaded.encoding.thaumaturgy@gmail.com'
6
6
  __maintainer_name__, __maintainer_email__ = __author_name__, __author_email__
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from enum import Enum
4
- from typing import Any, TypeVar
4
+ from typing import Any
5
5
 
6
6
  from typing_extensions import Self
7
7
 
@@ -9,7 +9,6 @@ from ..exceptions import CustomValueError, NotFoundEnumValue
9
9
  from ..types import FuncExceptT
10
10
 
11
11
  __all__ = [
12
- 'SelfEnum',
13
12
  'CustomEnum', 'CustomIntEnum', 'CustomStrEnum'
14
13
  ]
15
14
 
@@ -75,6 +74,3 @@ class CustomStrEnum(str, CustomEnum):
75
74
  """Base class for custom str enums."""
76
75
 
77
76
  value: str
78
-
79
-
80
- SelfEnum = TypeVar('SelfEnum', bound=CustomEnum)
@@ -3,12 +3,12 @@ from __future__ import annotations
3
3
  from typing import Any, Callable, ParamSpec, Sequence, SupportsFloat, SupportsIndex, TypeAlias, TypeVar, Union
4
4
 
5
5
  __all__ = [
6
- 'T', 'T0', 'T1', 'T2', 'T_contra',
6
+ 'T', 'T0', 'T1', 'T2', 'T_co', 'T0_co', 'T1_co', 'T_contra',
7
7
 
8
8
  'F', 'F0', 'F1', 'F2',
9
9
 
10
10
  'P', 'P0', 'P1', 'P2',
11
- 'R', 'R0', 'R1', 'R2', 'R_co', 'R0_co', 'R_contra',
11
+ 'R', 'R0', 'R1', 'R2', 'R_co', 'R0_co', 'R1_co', 'R_contra',
12
12
 
13
13
  'Nb',
14
14
 
@@ -45,8 +45,13 @@ R0 = TypeVar('R0')
45
45
  R1 = TypeVar('R1')
46
46
  R2 = TypeVar('R2')
47
47
 
48
+ T_co = TypeVar('T_co', covariant=True)
49
+ T0_co = TypeVar('T0_co', covariant=True)
50
+ T1_co = TypeVar('T1_co', covariant=True)
51
+
48
52
  R_co = TypeVar('R_co', covariant=True)
49
53
  R0_co = TypeVar('R0_co', covariant=True)
54
+ R1_co = TypeVar('R1_co', covariant=True)
50
55
 
51
56
  T_contra = TypeVar('T_contra', contravariant=True)
52
57
  R_contra = TypeVar('R_contra', contravariant=True)
@@ -5,12 +5,13 @@ from inspect import Signature
5
5
  from inspect import _empty as empty_param
6
6
  from inspect import isclass
7
7
  from typing import (
8
- TYPE_CHECKING, Any, Callable, Concatenate, Generator, Generic, Iterable, Iterator, Mapping,
9
- NoReturn, Protocol, Sequence, TypeVar, cast, overload
8
+ TYPE_CHECKING, Any, Callable, Concatenate, Generator, Generic, Iterable, Iterator, Mapping, NoReturn, Protocol,
9
+ Sequence, TypeVar, cast, overload
10
10
  )
11
+
11
12
  from typing_extensions import Self
12
13
 
13
- from .builtins import F0, F1, P0, P1, R0, R1, T0, T1, T2, KwargsT, P, R, R_co, R0_co, T
14
+ from .builtins import F0, F1, P0, P1, R0, R1, T0, T1, T2, KwargsT, P, R, R0_co, R1_co, R_co, T, T0_co, T1_co, T_co
14
15
 
15
16
  __all__ = [
16
17
  'copy_signature',
@@ -67,47 +68,33 @@ class copy_signature(Generic[F0]):
67
68
  return cast(F0, wrapped)
68
69
 
69
70
 
70
- class injected_self_func(Generic[T, P, R], Protocol): # type: ignore[misc]
71
- @overload
72
- @staticmethod
73
- def __call__(*args: P.args, **kwargs: P.kwargs) -> R:
74
- ...
75
-
76
- @overload
77
- @staticmethod
78
- def __call__(self: T, *args: P.args, **kwargs: P.kwargs) -> R:
79
- ...
80
-
71
+ class injected_self_func(Protocol[T_co, P, R_co]):
81
72
  @overload
82
73
  @staticmethod
83
- def __call__(self: T, _self: T, *args: P.args, **kwargs: P.kwargs) -> R:
74
+ def __call__(*args: P.args, **kwargs: P.kwargs) -> R_co:
84
75
  ...
85
76
 
86
77
  @overload
87
78
  @staticmethod
88
- def __call__(cls: type[T], *args: P.args, **kwargs: P.kwargs) -> R:
79
+ def __call__(self: T_co, *args: P.args, **kwargs: P.kwargs) -> R_co: # type: ignore[misc]
89
80
  ...
90
81
 
91
82
  @overload
92
83
  @staticmethod
93
- def __call__(cls: type[T], _cls: type[T], *args: P.args, **kwargs: P.kwargs) -> R:
94
- ...
95
-
96
- @staticmethod
97
- def __call__(*args: Any, **kwds: Any) -> Any:
84
+ def __call__(cls: type[T_co], *args: P.args, **kwargs: P.kwargs) -> R_co:
98
85
  ...
99
86
 
100
87
 
101
- self_objects_cache = dict[type, Any]()
88
+ self_objects_cache = dict[Any, Any]()
102
89
 
103
90
 
104
- class inject_self_base(Generic[T, P, R]):
91
+ class inject_self_base(Generic[T_co, P, R_co]):
105
92
  cache: bool | None
106
93
  signature: Signature | None
107
94
  init_kwargs: list[str] | None
108
95
  first_key: str | None
109
96
 
110
- def __init__(self, function: Callable[Concatenate[T, P], R], /, *, cache: bool = False) -> None:
97
+ def __init__(self, function: Callable[Concatenate[T_co, P], R_co], /, *, cache: bool = False) -> None:
111
98
  """
112
99
  Wrap ``function`` to always have a self provided to it.
113
100
 
@@ -130,8 +117,8 @@ class inject_self_base(Generic[T, P, R]):
130
117
  self.clean_kwargs = False
131
118
 
132
119
  def __get__(
133
- self, class_obj: type[T] | T | None, class_type: type[T] | type[type[T]] # type: ignore
134
- ) -> injected_self_func[T, P, R]:
120
+ self, class_obj: type[T] | T | None, class_type: type[T] | type[type[T]] | Any # type: ignore[valid-type]
121
+ ) -> injected_self_func[T_co, P, R_co]:
135
122
  if not self.signature or not self.first_key:
136
123
  self.signature = Signature.from_callable(self.function, eval_str=True)
137
124
  self.first_key = next(iter(list(self.signature.parameters.keys())), None)
@@ -187,8 +174,8 @@ class inject_self_base(Generic[T, P, R]):
187
174
 
188
175
  return _wrapper
189
176
 
190
- def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
191
- return self.__get__(None, self)(*args, **kwargs) # type: ignore
177
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R_co:
178
+ return self.__get__(None, self)(*args, **kwargs)
192
179
 
193
180
  @property
194
181
  def __signature__(self) -> Signature:
@@ -197,7 +184,7 @@ class inject_self_base(Generic[T, P, R]):
197
184
  @classmethod
198
185
  def with_args(
199
186
  cls, *args: Any, **kwargs: Any
200
- ) -> Callable[[Callable[Concatenate[T0, P0], R0]], inject_self[T0, P0, R0]]:
187
+ ) -> Callable[[Callable[Concatenate[T0_co, P0], R0_co]], inject_self[T0_co, P0, R0_co]]:
201
188
  """Provide custom args to instantiate the ``self`` object with."""
202
189
 
203
190
  def _wrapper(function: Callable[Concatenate[T0, P0], R0]) -> inject_self[T0, P0, R0]:
@@ -208,69 +195,71 @@ class inject_self_base(Generic[T, P, R]):
208
195
  return _wrapper
209
196
 
210
197
 
211
- class inject_self(Generic[T, P, R], inject_self_base[T, P, R]):
198
+ class inject_self(inject_self_base[T_co, P, R_co]):
212
199
  """Wrap a method so it always has a constructed ``self`` provided to it."""
213
200
 
214
- class cached(Generic[T0, P0, R0], inject_self_base[T0, P0, R0]):
201
+ class cached(inject_self_base[T0_co, P0, R0_co]):
215
202
  """
216
203
  Wrap a method so it always has a constructed ``self`` provided to it.
217
204
  Once ``self`` is constructed, it will be reused.
218
205
  """
219
206
 
220
- class property(Generic[T1, R1]):
221
- def __init__(self, function: Callable[[T1], R1]) -> None:
207
+ class property(Generic[T1_co, R1_co]):
208
+ def __init__(self, function: Callable[[T1_co], R1_co]) -> None:
222
209
  self.function = inject_self(function)
223
210
 
224
211
  def __get__(
225
- self, class_obj: type[T1] | T1 | None, class_type: type[T1] | type[type[T1]] # type: ignore
226
- ) -> R1:
212
+ self, class_obj: type[T1_co] | T1_co | None, class_type: type[T1_co] | T1_co
213
+ ) -> R1_co:
227
214
  return self.function.__get__(class_obj, class_type)()
228
215
 
229
- class init_kwargs(Generic[T0, P0, R0], inject_self_base[T0, P0, R0]):
216
+ class init_kwargs(inject_self_base[T0_co, P0, R0_co]):
230
217
  """
231
218
  Wrap a method so it always has a constructed ``self`` provided to it.
232
219
  When constructed, kwargs to the function will be passed to the constructor.
233
220
  """
234
221
 
235
222
  @classmethod
236
- def clean(cls, function: Callable[Concatenate[T1, P1], R1]) -> inject_self[T1, P1, R1]:
223
+ def clean(cls, function: Callable[Concatenate[T1_co, P1], R1_co]) -> inject_self[T1_co, P1, R1_co]:
237
224
  """Wrap a method, pass kwargs to the constructor and remove them from actual **kwargs."""
238
225
  inj = cls(function) # type: ignore
239
226
  inj.clean_kwargs = True
240
227
  return inj # type: ignore
241
228
 
242
- class property(Generic[T0, R0]):
243
- def __init__(self, function: Callable[[T0], R0]) -> None:
229
+ class property(Generic[T0_co, R0_co]):
230
+ def __init__(self, function: Callable[[T0_co], R0_co]) -> None:
244
231
  self.function = inject_self(function)
245
232
 
246
233
  def __get__(
247
- self, class_obj: type[T0] | T0 | None, class_type: type[T0] | type[type[T0]] # type: ignore
248
- ) -> R0:
234
+ self, class_obj: type[T0_co] | T0_co | None, class_type: type[T0_co] | T0_co
235
+ ) -> R0_co:
249
236
  return self.function.__get__(class_obj, class_type)()
250
237
 
251
238
 
252
- class inject_kwargs_params_base_func(Generic[T, P, R], Callable[Concatenate[T, P], R]): # type: ignore[misc]
253
- def __call__(self: T, *args: P.args, **kwargs: P.kwargs) -> R: # type: ignore
254
- ...
239
+ class inject_kwargs_params_base_func(Generic[T_co, P, R_co]):
240
+ def __call__(self: T_co, *args: P.args, **kwargs: P.kwargs) -> R_co:
241
+ raise NotImplementedError
242
+
255
243
 
244
+ class inject_kwargs_params_base(Generic[T_co, P, R_co]):
245
+ signature: Signature | None
256
246
 
257
- class inject_kwargs_params_base(Generic[T, P, R]):
258
247
  _kwargs_name = 'kwargs'
259
248
 
260
- def __init__(self, function: Callable[Concatenate[T, P], R]) -> None:
249
+ def __init__(self, function: Callable[Concatenate[T_co, P], R_co]) -> None:
261
250
  self.function = function
262
251
 
263
252
  self.signature = None
264
253
 
265
254
  def __get__(
266
255
  self, class_obj: T, class_type: type[T]
267
- ) -> inject_kwargs_params_base_func[T, P, R]:
256
+ ) -> inject_kwargs_params_base_func[T_co, P, R_co]:
268
257
  if not self.signature:
269
- self.signature = Signature.from_callable(self.function, eval_str=True) # type: ignore
258
+ self.signature = Signature.from_callable(self.function, eval_str=True)
270
259
 
271
260
  if (
272
- isinstance(self, inject_kwargs_params.add_to_kwargs) # type: ignore
273
- and (4 not in {x.kind for x in self.signature.parameters.values()}) # type: ignore
261
+ isinstance(self, inject_kwargs_params.add_to_kwargs) # type: ignore[arg-type]
262
+ and (4 not in {x.kind for x in self.signature.parameters.values()})
274
263
  ):
275
264
  from ..exceptions import CustomValueError
276
265
 
@@ -281,10 +270,10 @@ class inject_kwargs_params_base(Generic[T, P, R]):
281
270
  this = self
282
271
 
283
272
  @wraps(self.function)
284
- def _wrapper(self: T, *_args: P.args, **kwargs: P.kwargs) -> R:
273
+ def _wrapper(self: Any, *_args: Any, **kwargs: Any) -> R_co:
285
274
  assert this.signature
286
275
 
287
- if class_obj and not isinstance(self, class_type): # type: ignore
276
+ if class_obj and not isinstance(self, class_type):
288
277
  _args = (self, *_args)
289
278
  self = class_obj
290
279
 
@@ -318,14 +307,14 @@ class inject_kwargs_params_base(Generic[T, P, R]):
318
307
 
319
308
  kwargs[key] = kw_value
320
309
 
321
- if isinstance(this, inject_kwargs_params.add_to_kwargs):
310
+ if isinstance(this, inject_kwargs_params.add_to_kwargs): # type: ignore[arg-type]
322
311
  kwargs |= this_kwargs
323
312
 
324
313
  return this.function(self, *args, **kwargs)
325
314
 
326
315
  return _wrapper # type: ignore
327
316
 
328
- def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
317
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R_co:
329
318
  return self.__get__(None, self)(*args, **kwargs) # type: ignore
330
319
 
331
320
  @property
@@ -455,7 +444,7 @@ class classproperty(Generic[P, R, T, T0, P0]):
455
444
 
456
445
  self.doc = doc
457
446
 
458
- def _wrap(self, func: classmethod[T1, P1, R1] | Callable[P1, R1]) -> classmethod[T1, P1, R1]:
447
+ def _wrap(self, func: classmethod[T1, P1, R1] | Callable[P1, R1] | Callable[..., R1]) -> classmethod[T1, P1, R1]:
459
448
  if not isinstance(func, (classmethod, staticmethod)):
460
449
  func = classmethod(func) # type: ignore
461
450
 
@@ -490,7 +479,7 @@ class classproperty(Generic[P, R, T, T0, P0]):
490
479
  else:
491
480
  type_ = type(__obj)
492
481
 
493
- return self.fset.__get__(__obj, type_)(__value)
482
+ return self.fset.__get__(__obj, type_)(__value) # type: ignore[call-arg]
494
483
 
495
484
  def __delete__(self, __obj: Any) -> None:
496
485
  from ..exceptions import CustomError
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 1.2.7
3
+ Version: 1.3.0
4
4
  Summary: Collection of stuff that's useful in general python programming
5
5
  Author: Jaded Encoding Thaumaturgy
6
6
  Author-email: jaded.encoding.thaumaturgy@gmail.com
@@ -18,14 +18,17 @@ Classifier: Typing :: Typed
18
18
  Requires-Python: >=3.10
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Requires-Dist: typing_extensions>=4.12.2
21
22
  Dynamic: author
22
23
  Dynamic: author-email
23
24
  Dynamic: classifier
24
25
  Dynamic: description
25
26
  Dynamic: description-content-type
27
+ Dynamic: license-file
26
28
  Dynamic: maintainer
27
29
  Dynamic: maintainer-email
28
30
  Dynamic: project-url
31
+ Dynamic: requires-dist
29
32
  Dynamic: requires-python
30
33
  Dynamic: summary
31
34
 
@@ -8,6 +8,7 @@ jetpytools/py.typed
8
8
  jetpytools.egg-info/PKG-INFO
9
9
  jetpytools.egg-info/SOURCES.txt
10
10
  jetpytools.egg-info/dependency_links.txt
11
+ jetpytools.egg-info/requires.txt
11
12
  jetpytools.egg-info/top_level.txt
12
13
  jetpytools/enums/__init__.py
13
14
  jetpytools/enums/base.py
@@ -0,0 +1 @@
1
+ typing_extensions>=4.12.2
@@ -25,6 +25,7 @@ setuptools.setup(
25
25
  'Source Code': 'https://github.com/Jaded-Encoding-Thaumaturgy/jetpytools',
26
26
  'Contact': 'https://discord.gg/XTpc6Fa9eB',
27
27
  },
28
+ install_requires="typing_extensions>=4.12.2",
28
29
  python_requires='>=3.10',
29
30
  packages=[
30
31
  package_name,
File without changes
File without changes
File without changes