jetpytools 1.4.0__py3-none-any.whl → 1.6.0__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.
- jetpytools/__init__.py +5 -5
- jetpytools/_metadata.py +4 -4
- jetpytools/enums/__init__.py +2 -2
- jetpytools/enums/base.py +9 -8
- jetpytools/enums/other.py +4 -9
- jetpytools/exceptions/__init__.py +5 -5
- jetpytools/exceptions/base.py +34 -38
- jetpytools/exceptions/enum.py +5 -4
- jetpytools/exceptions/file.py +6 -8
- jetpytools/exceptions/generic.py +8 -6
- jetpytools/exceptions/module.py +9 -8
- jetpytools/functions/__init__.py +3 -3
- jetpytools/functions/funcs.py +61 -38
- jetpytools/functions/normalize.py +110 -65
- jetpytools/functions/other.py +1 -3
- jetpytools/types/__init__.py +7 -7
- jetpytools/types/builtins.py +62 -43
- jetpytools/types/check.py +6 -9
- jetpytools/types/file.py +97 -48
- jetpytools/types/funcs.py +11 -28
- jetpytools/types/generic.py +1 -11
- jetpytools/types/supports.py +68 -52
- jetpytools/types/utils.py +102 -119
- jetpytools/utils/__init__.py +4 -4
- jetpytools/utils/file.py +94 -69
- jetpytools/utils/funcs.py +8 -13
- jetpytools/utils/math.py +29 -17
- jetpytools/utils/ranges.py +7 -11
- {jetpytools-1.4.0.dist-info → jetpytools-1.6.0.dist-info}/METADATA +10 -23
- jetpytools-1.6.0.dist-info/RECORD +33 -0
- {jetpytools-1.4.0.dist-info → jetpytools-1.6.0.dist-info}/WHEEL +1 -2
- jetpytools-1.4.0.dist-info/RECORD +0 -34
- jetpytools-1.4.0.dist-info/top_level.txt +0 -1
- {jetpytools-1.4.0.dist-info → jetpytools-1.6.0.dist-info}/licenses/LICENSE +0 -0
jetpytools/types/file.py
CHANGED
|
@@ -2,30 +2,30 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import fnmatch
|
|
4
4
|
import shutil
|
|
5
|
-
|
|
6
|
-
from os import PathLike, listdir, path, walk
|
|
5
|
+
from os import X_OK, PathLike, access, listdir, path, walk
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
from sys import version_info
|
|
9
8
|
from typing import TYPE_CHECKING, Any, Callable, Iterable, Literal, TypeAlias, Union
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
'FilePathType', 'FileDescriptor',
|
|
13
|
-
'FileOpener',
|
|
14
|
-
|
|
15
|
-
'OpenTextModeUpdating',
|
|
16
|
-
'OpenTextModeWriting',
|
|
17
|
-
'OpenTextModeReading',
|
|
18
|
-
|
|
19
|
-
'OpenBinaryModeUpdating',
|
|
20
|
-
'OpenBinaryModeWriting',
|
|
21
|
-
'OpenBinaryModeReading',
|
|
22
|
-
|
|
23
|
-
'OpenTextMode',
|
|
24
|
-
'OpenBinaryMode',
|
|
10
|
+
from typing_extensions import Self
|
|
25
11
|
|
|
26
|
-
|
|
12
|
+
__all__ = [
|
|
13
|
+
"FileDescriptor",
|
|
14
|
+
"FileOpener",
|
|
15
|
+
"FilePathType",
|
|
16
|
+
"OpenBinaryMode",
|
|
17
|
+
"OpenBinaryModeReading",
|
|
18
|
+
"OpenBinaryModeUpdating",
|
|
19
|
+
"OpenBinaryModeWriting",
|
|
20
|
+
"OpenTextMode",
|
|
21
|
+
"OpenTextModeReading",
|
|
22
|
+
"OpenTextModeUpdating",
|
|
23
|
+
"OpenTextModeWriting",
|
|
24
|
+
"SPath",
|
|
25
|
+
"SPathLike",
|
|
27
26
|
]
|
|
28
27
|
|
|
28
|
+
|
|
29
29
|
FileDescriptor: TypeAlias = int
|
|
30
30
|
|
|
31
31
|
FilePathType: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes]
|
|
@@ -33,26 +33,70 @@ FilePathType: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes]
|
|
|
33
33
|
FileOpener: TypeAlias = Callable[[str, int], int]
|
|
34
34
|
|
|
35
35
|
OpenTextModeUpdating: TypeAlias = Literal[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
"r+",
|
|
37
|
+
"+r",
|
|
38
|
+
"rt+",
|
|
39
|
+
"r+t",
|
|
40
|
+
"+rt",
|
|
41
|
+
"tr+",
|
|
42
|
+
"t+r",
|
|
43
|
+
"+tr",
|
|
44
|
+
"w+",
|
|
45
|
+
"+w",
|
|
46
|
+
"wt+",
|
|
47
|
+
"w+t",
|
|
48
|
+
"+wt",
|
|
49
|
+
"tw+",
|
|
50
|
+
"t+w",
|
|
51
|
+
"+tw",
|
|
52
|
+
"a+",
|
|
53
|
+
"+a",
|
|
54
|
+
"at+",
|
|
55
|
+
"a+t",
|
|
56
|
+
"+at",
|
|
57
|
+
"ta+",
|
|
58
|
+
"t+a",
|
|
59
|
+
"+ta",
|
|
60
|
+
"x+",
|
|
61
|
+
"+x",
|
|
62
|
+
"xt+",
|
|
63
|
+
"x+t",
|
|
64
|
+
"+xt",
|
|
65
|
+
"tx+",
|
|
66
|
+
"t+x",
|
|
67
|
+
"+tx",
|
|
44
68
|
]
|
|
69
|
+
OpenTextModeWriting: TypeAlias = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
|
|
70
|
+
OpenTextModeReading: TypeAlias = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
|
|
45
71
|
|
|
46
72
|
OpenBinaryModeUpdating: TypeAlias = Literal[
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
"rb+",
|
|
74
|
+
"r+b",
|
|
75
|
+
"+rb",
|
|
76
|
+
"br+",
|
|
77
|
+
"b+r",
|
|
78
|
+
"+br",
|
|
79
|
+
"wb+",
|
|
80
|
+
"w+b",
|
|
81
|
+
"+wb",
|
|
82
|
+
"bw+",
|
|
83
|
+
"b+w",
|
|
84
|
+
"+bw",
|
|
85
|
+
"ab+",
|
|
86
|
+
"a+b",
|
|
87
|
+
"+ab",
|
|
88
|
+
"ba+",
|
|
89
|
+
"b+a",
|
|
90
|
+
"+ba",
|
|
91
|
+
"xb+",
|
|
92
|
+
"x+b",
|
|
93
|
+
"+xb",
|
|
94
|
+
"bx+",
|
|
95
|
+
"b+x",
|
|
96
|
+
"+bx",
|
|
55
97
|
]
|
|
98
|
+
OpenBinaryModeWriting: TypeAlias = Literal["wb", "bw", "ab", "ba", "xb", "bx"]
|
|
99
|
+
OpenBinaryModeReading: TypeAlias = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"]
|
|
56
100
|
|
|
57
101
|
OpenTextMode: TypeAlias = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading
|
|
58
102
|
OpenBinaryMode: TypeAlias = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting
|
|
@@ -60,12 +104,13 @@ OpenBinaryMode: TypeAlias = OpenBinaryModeUpdating | OpenBinaryModeReading | Ope
|
|
|
60
104
|
|
|
61
105
|
class SPath(Path):
|
|
62
106
|
"""Modified version of pathlib.Path"""
|
|
107
|
+
|
|
63
108
|
if version_info < (3, 12):
|
|
64
109
|
_flavour = type(Path())._flavour # type: ignore
|
|
65
110
|
|
|
66
111
|
if TYPE_CHECKING:
|
|
67
|
-
|
|
68
|
-
|
|
112
|
+
|
|
113
|
+
def __new__(cls, *args: SPathLike, **kwargs: Any) -> Self: ...
|
|
69
114
|
|
|
70
115
|
def format(self, *args: Any, **kwargs: Any) -> SPath:
|
|
71
116
|
"""Format the path with the given arguments."""
|
|
@@ -101,22 +146,19 @@ class SPath(Path):
|
|
|
101
146
|
if not missing_ok:
|
|
102
147
|
raise
|
|
103
148
|
|
|
104
|
-
def read_lines(
|
|
105
|
-
self, encoding: str | None = None, errors: str | None = None, keepends: bool = False
|
|
106
|
-
) -> list[str]:
|
|
149
|
+
def read_lines(self, encoding: str | None = None, errors: str | None = None, keepends: bool = False) -> list[str]:
|
|
107
150
|
"""Read the file and return its lines."""
|
|
108
151
|
|
|
109
152
|
return super().read_text(encoding, errors).splitlines(keepends)
|
|
110
153
|
|
|
111
154
|
def write_lines(
|
|
112
|
-
self, data: Iterable[str], encoding: str | None = None,
|
|
113
|
-
errors: str | None = None, newline: str | None = None
|
|
155
|
+
self, data: Iterable[str], encoding: str | None = None, errors: str | None = None, newline: str | None = None
|
|
114
156
|
) -> int:
|
|
115
157
|
"""Open the file and write the given lines."""
|
|
116
158
|
|
|
117
|
-
return super().write_text(
|
|
159
|
+
return super().write_text("\n".join(data), encoding, errors, newline)
|
|
118
160
|
|
|
119
|
-
def append_to_stem(self, suffixes: str | Iterable[str], sep: str =
|
|
161
|
+
def append_to_stem(self, suffixes: str | Iterable[str], sep: str = "_") -> SPath:
|
|
120
162
|
"""Append a suffix to the stem of the path"""
|
|
121
163
|
|
|
122
164
|
from ..functions import to_arr
|
|
@@ -149,19 +191,20 @@ class SPath(Path):
|
|
|
149
191
|
|
|
150
192
|
if not self.is_dir():
|
|
151
193
|
from ..exceptions import PathIsNotADirectoryError
|
|
152
|
-
|
|
194
|
+
|
|
195
|
+
raise PathIsNotADirectoryError('The given path, "{self}" is not a directory!', self.copy_dir)
|
|
153
196
|
|
|
154
197
|
dst.mkdirp()
|
|
155
198
|
shutil.copytree(self, dst, dirs_exist_ok=True)
|
|
156
199
|
|
|
157
200
|
return SPath(dst)
|
|
158
201
|
|
|
159
|
-
def lglob(self, pattern: str =
|
|
202
|
+
def lglob(self, pattern: str = "*") -> list[SPath]:
|
|
160
203
|
"""Glob the path and return the list of paths."""
|
|
161
204
|
|
|
162
205
|
return list(map(SPath, self.glob(pattern)))
|
|
163
206
|
|
|
164
|
-
def fglob(self, pattern: str =
|
|
207
|
+
def fglob(self, pattern: str = "*") -> SPath | None:
|
|
165
208
|
"""Glob the path and return the first match."""
|
|
166
209
|
|
|
167
210
|
for root, dirs, files in walk(self):
|
|
@@ -171,7 +214,7 @@ class SPath(Path):
|
|
|
171
214
|
|
|
172
215
|
return None
|
|
173
216
|
|
|
174
|
-
def find_newest_file(self, pattern: str =
|
|
217
|
+
def find_newest_file(self, pattern: str = "*") -> SPath | None:
|
|
175
218
|
"""Find the most recently modified file matching the given pattern in the directory."""
|
|
176
219
|
|
|
177
220
|
matching_files = self.get_folder().glob(pattern)
|
|
@@ -188,12 +231,18 @@ class SPath(Path):
|
|
|
188
231
|
|
|
189
232
|
if not self.exists():
|
|
190
233
|
from ..exceptions import FileNotExistsError
|
|
191
|
-
|
|
234
|
+
|
|
235
|
+
raise FileNotExistsError('The given path, "{self}" is not a file or directory!', self.get_size)
|
|
192
236
|
|
|
193
237
|
if self.is_file():
|
|
194
238
|
return self.stat().st_size
|
|
195
239
|
|
|
196
|
-
return sum(f.stat().st_size for f in self.rglob(
|
|
240
|
+
return sum(f.stat().st_size for f in self.rglob("*") if f.is_file())
|
|
241
|
+
|
|
242
|
+
def is_executable(self) -> bool:
|
|
243
|
+
"""Check if the path is executable."""
|
|
244
|
+
|
|
245
|
+
return access(self.to_str(), X_OK)
|
|
197
246
|
|
|
198
247
|
|
|
199
248
|
SPathLike = Union[str, PathLike[str], Path, SPath]
|
jetpytools/types/funcs.py
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import wraps
|
|
4
|
-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, SupportsIndex, TypeAlias
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, SupportsIndex, TypeAlias
|
|
5
5
|
|
|
6
6
|
from typing_extensions import Self, TypeIs
|
|
7
7
|
|
|
8
8
|
from .builtins import P, T
|
|
9
9
|
from .supports import SupportsString
|
|
10
10
|
|
|
11
|
-
__all__ = [
|
|
12
|
-
'StrList',
|
|
13
|
-
'Sentinel',
|
|
14
|
-
'SentinelT'
|
|
15
|
-
]
|
|
11
|
+
__all__ = ["Sentinel", "SentinelT", "StrList"]
|
|
16
12
|
|
|
17
13
|
|
|
18
14
|
class StrList(list[SupportsString]):
|
|
19
15
|
"""Custom class for representing a recursively "stringable" list."""
|
|
20
16
|
|
|
21
17
|
if TYPE_CHECKING:
|
|
22
|
-
@overload
|
|
23
|
-
def __init__(self, __iterable: Iterable[SupportsString | None] = []) -> None:
|
|
24
|
-
...
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
def __init__(self, __iterable: Iterable[Iterable[SupportsString | None] | None] = []) -> None:
|
|
28
|
-
...
|
|
29
|
-
|
|
30
|
-
def __init__(self, __iterable: Any = []) -> None:
|
|
31
|
-
...
|
|
19
|
+
def __init__(self, iterable: Iterable[SupportsString | None] | None = ..., /) -> None: ...
|
|
32
20
|
|
|
33
21
|
@property
|
|
34
22
|
def string(self) -> str:
|
|
@@ -40,21 +28,16 @@ class StrList(list[SupportsString]):
|
|
|
40
28
|
def __str__(self) -> str:
|
|
41
29
|
from ..functions import flatten
|
|
42
30
|
|
|
43
|
-
return
|
|
44
|
-
filter(
|
|
45
|
-
None,
|
|
46
|
-
(str(x).strip() for x in flatten(self) if x is not None)
|
|
47
|
-
)
|
|
48
|
-
)
|
|
31
|
+
return " ".join(filter(None, (str(x).strip() for x in flatten(self) if x is not None)))
|
|
49
32
|
|
|
50
|
-
def __add__(self,
|
|
51
|
-
return StrList(super().__add__(
|
|
33
|
+
def __add__(self, x: list[SupportsString]) -> StrList: # type: ignore[override]
|
|
34
|
+
return StrList(super().__add__(x))
|
|
52
35
|
|
|
53
|
-
def __mul__(self,
|
|
54
|
-
return StrList(super().__mul__(
|
|
36
|
+
def __mul__(self, n: SupportsIndex) -> StrList:
|
|
37
|
+
return StrList(super().__mul__(n))
|
|
55
38
|
|
|
56
|
-
def __rmul__(self,
|
|
57
|
-
return StrList(super().__rmul__(
|
|
39
|
+
def __rmul__(self, n: SupportsIndex) -> StrList:
|
|
40
|
+
return StrList(super().__rmul__(n))
|
|
58
41
|
|
|
59
42
|
@property
|
|
60
43
|
def mlength(self) -> int:
|
|
@@ -98,7 +81,7 @@ class SentinelDispatcher:
|
|
|
98
81
|
_sentinels[name] = SentinelDispatcher()
|
|
99
82
|
return _sentinels[name]
|
|
100
83
|
|
|
101
|
-
def __setattr__(self,
|
|
84
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
102
85
|
raise NameError
|
|
103
86
|
|
|
104
87
|
def __call__(self) -> SentinelDispatcher:
|
jetpytools/types/generic.py
CHANGED
|
@@ -6,17 +6,7 @@ from typing import Any, Callable, Literal, TypeAlias, Union
|
|
|
6
6
|
from .builtins import F, SingleOrArr, SingleOrArrOpt
|
|
7
7
|
from .supports import SupportsString
|
|
8
8
|
|
|
9
|
-
__all__ = [
|
|
10
|
-
'MissingT', 'MISSING',
|
|
11
|
-
|
|
12
|
-
'FuncExceptT',
|
|
13
|
-
|
|
14
|
-
'DataType',
|
|
15
|
-
|
|
16
|
-
'StrArr', 'StrArrOpt',
|
|
17
|
-
|
|
18
|
-
'PassthroughC'
|
|
19
|
-
]
|
|
9
|
+
__all__ = ["MISSING", "DataType", "FuncExceptT", "MissingT", "PassthroughC", "StrArr", "StrArrOpt"]
|
|
20
10
|
|
|
21
11
|
|
|
22
12
|
class MissingTBase(Enum):
|
jetpytools/types/supports.py
CHANGED
|
@@ -2,126 +2,142 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from abc import abstractmethod
|
|
4
4
|
from typing import (
|
|
5
|
-
Any,
|
|
5
|
+
Any,
|
|
6
|
+
Callable,
|
|
7
|
+
Iterable,
|
|
8
|
+
Protocol,
|
|
9
|
+
SupportsFloat,
|
|
10
|
+
SupportsIndex,
|
|
11
|
+
TypeAlias,
|
|
12
|
+
TypeVar,
|
|
13
|
+
overload,
|
|
14
|
+
runtime_checkable,
|
|
6
15
|
)
|
|
7
16
|
|
|
8
|
-
from .builtins import T0, T1, T2, T_contra
|
|
17
|
+
from .builtins import T0, T1, T2, T_co, T_contra
|
|
9
18
|
|
|
10
19
|
__all__ = [
|
|
11
|
-
|
|
20
|
+
"ComparatorFunc",
|
|
21
|
+
"SupportsAdd",
|
|
22
|
+
"SupportsAllComparisons",
|
|
23
|
+
"SupportsDunderGE",
|
|
24
|
+
"SupportsDunderGT",
|
|
25
|
+
"SupportsDunderLE",
|
|
26
|
+
"SupportsDunderLT",
|
|
27
|
+
"SupportsFloatOrIndex",
|
|
28
|
+
"SupportsIndexing",
|
|
29
|
+
"SupportsKeysAndGetItem",
|
|
30
|
+
"SupportsRAdd",
|
|
31
|
+
"SupportsRichComparison",
|
|
32
|
+
"SupportsRichComparisonT",
|
|
33
|
+
"SupportsString",
|
|
34
|
+
"SupportsSumNoDefaultT",
|
|
35
|
+
"SupportsTrunc",
|
|
36
|
+
]
|
|
37
|
+
|
|
12
38
|
|
|
13
|
-
|
|
39
|
+
_KT = TypeVar("_KT")
|
|
40
|
+
_VT_co = TypeVar("_VT_co", covariant=True)
|
|
14
41
|
|
|
15
|
-
'SupportsDunderLT', 'SupportsDunderGT',
|
|
16
|
-
'SupportsDunderLE', 'SupportsDunderGE',
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
@runtime_checkable
|
|
44
|
+
class SupportsAdd(Protocol[T_contra, T_co]):
|
|
45
|
+
def __add__(self, x: T_contra, /) -> T_co: ...
|
|
19
46
|
|
|
20
|
-
'SupportsIndexing',
|
|
21
|
-
'SupportsKeysAndGetItem',
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
48
|
+
@runtime_checkable
|
|
49
|
+
class SupportsRAdd(Protocol[T_contra, T_co]):
|
|
50
|
+
def __radd__(self, x: T_contra, /) -> T_co: ...
|
|
51
|
+
|
|
27
52
|
|
|
53
|
+
class _SupportsSumWithNoDefaultGiven(SupportsAdd[Any, Any], SupportsRAdd[int, Any], Protocol): ...
|
|
28
54
|
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
|
|
56
|
+
SupportsSumNoDefaultT = TypeVar("SupportsSumNoDefaultT", bound=_SupportsSumWithNoDefaultGiven)
|
|
31
57
|
|
|
32
58
|
|
|
33
59
|
@runtime_checkable
|
|
34
60
|
class SupportsTrunc(Protocol):
|
|
35
|
-
def __trunc__(self) -> int:
|
|
36
|
-
...
|
|
61
|
+
def __trunc__(self) -> int: ...
|
|
37
62
|
|
|
38
63
|
|
|
39
64
|
@runtime_checkable
|
|
40
65
|
class SupportsString(Protocol):
|
|
41
66
|
@abstractmethod
|
|
42
|
-
def __str__(self) -> str:
|
|
43
|
-
...
|
|
67
|
+
def __str__(self) -> str: ...
|
|
44
68
|
|
|
45
69
|
|
|
46
70
|
@runtime_checkable
|
|
47
71
|
class SupportsDunderLT(Protocol[T_contra]):
|
|
48
|
-
def __lt__(self,
|
|
49
|
-
...
|
|
72
|
+
def __lt__(self, other: T_contra) -> bool: ...
|
|
50
73
|
|
|
51
74
|
|
|
52
75
|
@runtime_checkable
|
|
53
76
|
class SupportsDunderGT(Protocol[T_contra]):
|
|
54
|
-
def __gt__(self,
|
|
55
|
-
...
|
|
77
|
+
def __gt__(self, other: T_contra) -> bool: ...
|
|
56
78
|
|
|
57
79
|
|
|
58
80
|
@runtime_checkable
|
|
59
81
|
class SupportsDunderLE(Protocol[T_contra]):
|
|
60
|
-
def __le__(self,
|
|
61
|
-
...
|
|
82
|
+
def __le__(self, other: T_contra) -> bool: ...
|
|
62
83
|
|
|
63
84
|
|
|
64
85
|
@runtime_checkable
|
|
65
86
|
class SupportsDunderGE(Protocol[T_contra]):
|
|
66
|
-
def __ge__(self,
|
|
67
|
-
...
|
|
87
|
+
def __ge__(self, other: T_contra) -> bool: ...
|
|
68
88
|
|
|
69
89
|
|
|
70
90
|
@runtime_checkable
|
|
71
91
|
class SupportsAllComparisons(
|
|
72
92
|
SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
|
|
73
|
-
):
|
|
74
|
-
...
|
|
93
|
+
): ...
|
|
75
94
|
|
|
76
95
|
|
|
77
96
|
SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any]
|
|
78
|
-
SupportsRichComparisonT = TypeVar(
|
|
97
|
+
SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison)
|
|
79
98
|
|
|
80
99
|
|
|
81
100
|
class ComparatorFunc(Protocol):
|
|
82
101
|
@overload
|
|
83
102
|
def __call__(
|
|
84
|
-
self,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
self,
|
|
104
|
+
arg1: SupportsRichComparisonT,
|
|
105
|
+
arg2: SupportsRichComparisonT,
|
|
106
|
+
/,
|
|
107
|
+
*args: SupportsRichComparisonT,
|
|
108
|
+
key: None = ...,
|
|
109
|
+
) -> SupportsRichComparisonT: ...
|
|
88
110
|
|
|
89
111
|
@overload
|
|
90
|
-
def __call__(self,
|
|
91
|
-
...
|
|
112
|
+
def __call__(self, arg1: T0, arg2: T0, /, *_args: T0, key: Callable[[T0], SupportsRichComparison]) -> T0: ...
|
|
92
113
|
|
|
93
114
|
@overload
|
|
94
|
-
def __call__(
|
|
95
|
-
...
|
|
115
|
+
def __call__(
|
|
116
|
+
self, iterable: Iterable[SupportsRichComparisonT], /, *, key: None = ...
|
|
117
|
+
) -> SupportsRichComparisonT: ...
|
|
96
118
|
|
|
97
119
|
@overload
|
|
98
|
-
def __call__(self,
|
|
99
|
-
...
|
|
120
|
+
def __call__(self, iterable: Iterable[T0], /, *, key: Callable[[T0], SupportsRichComparison]) -> T0: ...
|
|
100
121
|
|
|
101
122
|
@overload
|
|
102
123
|
def __call__(
|
|
103
|
-
self,
|
|
104
|
-
) -> SupportsRichComparisonT | T0:
|
|
105
|
-
...
|
|
124
|
+
self, iterable: Iterable[SupportsRichComparisonT], /, *, key: None = ..., default: T0
|
|
125
|
+
) -> SupportsRichComparisonT | T0: ...
|
|
106
126
|
|
|
107
127
|
@overload
|
|
108
128
|
def __call__(
|
|
109
|
-
self,
|
|
110
|
-
) -> T1 | T2:
|
|
111
|
-
...
|
|
129
|
+
self, iterable: Iterable[T1], /, *, key: Callable[[T1], SupportsRichComparison], default: T2
|
|
130
|
+
) -> T1 | T2: ...
|
|
112
131
|
|
|
113
132
|
|
|
114
133
|
class SupportsIndexing(Protocol[_VT_co]):
|
|
115
|
-
def __getitem__(self,
|
|
116
|
-
...
|
|
134
|
+
def __getitem__(self, k: int) -> _VT_co: ...
|
|
117
135
|
|
|
118
136
|
|
|
119
137
|
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
|
|
120
|
-
def keys(self) -> Iterable[_KT]:
|
|
121
|
-
...
|
|
138
|
+
def keys(self) -> Iterable[_KT]: ...
|
|
122
139
|
|
|
123
|
-
def __getitem__(self,
|
|
124
|
-
...
|
|
140
|
+
def __getitem__(self, k: _KT) -> _VT_co: ...
|
|
125
141
|
|
|
126
142
|
|
|
127
143
|
SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
|