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

@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ from enum import Enum, auto
4
+ from typing import Any, Callable, Literal, TypeAlias, Union
5
+
6
+ from .builtins import F, SingleOrArr, SingleOrArrOpt
7
+ from .supports import SupportsString
8
+
9
+ __all__ = [
10
+ 'MissingT', 'MISSING',
11
+
12
+ 'FuncExceptT',
13
+
14
+ 'DataType',
15
+
16
+ 'StrArr', 'StrArrOpt',
17
+
18
+ 'PassthroughC'
19
+ ]
20
+
21
+
22
+ class MissingTBase(Enum):
23
+ MissingT = auto()
24
+
25
+
26
+ MissingT: TypeAlias = Literal[MissingTBase.MissingT]
27
+ MISSING = MissingTBase.MissingT
28
+
29
+ DataType = Union[str, bytes, bytearray, SupportsString]
30
+
31
+ FuncExceptT = str | Callable[..., Any] | tuple[Callable[..., Any] | str, str]
32
+ """
33
+ This type is used in specific functions that can throw an exception.
34
+ ```
35
+ def can_throw(..., *, func: FuncExceptT) -> None:
36
+ ...
37
+ if some_error:
38
+ raise CustomValueError('Some error occurred!!', func)
39
+
40
+ def some_func() -> None:
41
+ ...
42
+ can_throw(..., func=some_func)
43
+ ```
44
+ If an error occurs, this will print a clear error ->\n
45
+ ``ValueError: (some_func) Some error occurred!!``
46
+ """
47
+
48
+
49
+ StrArr = SingleOrArr[SupportsString]
50
+ StrArrOpt = SingleOrArrOpt[SupportsString]
51
+
52
+ PassthroughC = Callable[[F], F]
@@ -0,0 +1,127 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Any, Callable, Iterable, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar, overload, runtime_checkable
6
+ )
7
+
8
+ from .builtins import T0, T1, T2, T_contra
9
+
10
+ __all__ = [
11
+ 'SupportsTrunc',
12
+
13
+ 'SupportsString',
14
+
15
+ 'SupportsDunderLT', 'SupportsDunderGT',
16
+ 'SupportsDunderLE', 'SupportsDunderGE',
17
+
18
+ 'SupportsFloatOrIndex',
19
+
20
+ 'SupportsIndexing',
21
+ 'SupportsKeysAndGetItem',
22
+
23
+ 'SupportsAllComparisons',
24
+ 'SupportsRichComparison', 'SupportsRichComparisonT',
25
+ 'ComparatorFunc'
26
+ ]
27
+
28
+
29
+ _KT = TypeVar('_KT')
30
+ _VT_co = TypeVar('_VT_co', covariant=True)
31
+
32
+
33
+ @runtime_checkable
34
+ class SupportsTrunc(Protocol):
35
+ def __trunc__(self) -> int:
36
+ ...
37
+
38
+
39
+ @runtime_checkable
40
+ class SupportsString(Protocol):
41
+ @abstractmethod
42
+ def __str__(self) -> str:
43
+ ...
44
+
45
+
46
+ @runtime_checkable
47
+ class SupportsDunderLT(Protocol[T_contra]):
48
+ def __lt__(self, __other: T_contra) -> bool:
49
+ ...
50
+
51
+
52
+ @runtime_checkable
53
+ class SupportsDunderGT(Protocol[T_contra]):
54
+ def __gt__(self, __other: T_contra) -> bool:
55
+ ...
56
+
57
+
58
+ @runtime_checkable
59
+ class SupportsDunderLE(Protocol[T_contra]):
60
+ def __le__(self, __other: T_contra) -> bool:
61
+ ...
62
+
63
+
64
+ @runtime_checkable
65
+ class SupportsDunderGE(Protocol[T_contra]):
66
+ def __ge__(self, __other: T_contra) -> bool:
67
+ ...
68
+
69
+
70
+ @runtime_checkable
71
+ class SupportsAllComparisons(
72
+ SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
73
+ ):
74
+ ...
75
+
76
+
77
+ SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any]
78
+ SupportsRichComparisonT = TypeVar('SupportsRichComparisonT', bound=SupportsRichComparison)
79
+
80
+
81
+ class ComparatorFunc(Protocol):
82
+ @overload
83
+ def __call__(
84
+ self, __arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT,
85
+ *_args: SupportsRichComparisonT, key: None = ...
86
+ ) -> SupportsRichComparisonT:
87
+ ...
88
+
89
+ @overload
90
+ def __call__(self, __arg1: T0, __arg2: T0, *_args: T0, key: Callable[[T0], SupportsRichComparison]) -> T0:
91
+ ...
92
+
93
+ @overload
94
+ def __call__(self, __iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT:
95
+ ...
96
+
97
+ @overload
98
+ def __call__(self, __iterable: Iterable[T0], *, key: Callable[[T0], SupportsRichComparison]) -> T0:
99
+ ...
100
+
101
+ @overload
102
+ def __call__(
103
+ self, __iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: T0
104
+ ) -> SupportsRichComparisonT | T0:
105
+ ...
106
+
107
+ @overload
108
+ def __call__(
109
+ self, __iterable: Iterable[T1], *, key: Callable[[T1], SupportsRichComparison], default: T2
110
+ ) -> T1 | T2:
111
+ ...
112
+
113
+
114
+ class SupportsIndexing(Protocol[_VT_co]):
115
+ def __getitem__(self, __k: int) -> _VT_co:
116
+ ...
117
+
118
+
119
+ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
120
+ def keys(self) -> Iterable[_KT]:
121
+ ...
122
+
123
+ def __getitem__(self, __k: _KT) -> _VT_co:
124
+ ...
125
+
126
+
127
+ SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex