cmp3 0.3.0__tar.gz → 0.4.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.
- {cmp3-0.3.0/src/cmp3.egg-info → cmp3-0.4.0}/PKG-INFO +1 -1
- {cmp3-0.3.0 → cmp3-0.4.0}/pyproject.toml +1 -1
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3/core/__init__.py +9 -14
- {cmp3-0.3.0 → cmp3-0.4.0/src/cmp3.egg-info}/PKG-INFO +1 -1
- {cmp3-0.3.0 → cmp3-0.4.0}/LICENSE.txt +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/MANIFEST.in +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/README.rst +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/setup.cfg +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3/__init__.py +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3/tests/__init__.py +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3/tests/test_1984.py +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3.egg-info/SOURCES.txt +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3.egg-info/dependency_links.txt +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3.egg-info/requires.txt +0 -0
- {cmp3-0.3.0 → cmp3-0.4.0}/src/cmp3.egg-info/top_level.txt +0 -0
|
@@ -4,38 +4,35 @@ from typing import *
|
|
|
4
4
|
|
|
5
5
|
import setdoc
|
|
6
6
|
|
|
7
|
-
__all__ = ["Comparable", "comparable"
|
|
7
|
+
__all__ = ["Comparable", "comparable"]
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def comparable(
|
|
11
|
-
"This
|
|
12
|
-
return partial(update_rich_cmp, overwrites=overwrites)
|
|
10
|
+
def comparable(cls: type, /) -> type:
|
|
11
|
+
"This decorator enforces the use of __cmp__ upon a class."
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
|
|
16
13
|
@setdoc.basic
|
|
17
14
|
def __eq__(self: Self, other: Any) -> Any:
|
|
18
|
-
return self.__cmp__(other)
|
|
15
|
+
return self.__cmp__(other).__eq__(0)
|
|
19
16
|
|
|
20
17
|
@setdoc.basic
|
|
21
18
|
def __ge__(self: Self, other: Any) -> Any:
|
|
22
|
-
return self.__cmp__(other)
|
|
19
|
+
return self.__cmp__(other).__ge__(0)
|
|
23
20
|
|
|
24
21
|
@setdoc.basic
|
|
25
22
|
def __gt__(self: Self, other: Any) -> Any:
|
|
26
|
-
return self.__cmp__(other)
|
|
23
|
+
return self.__cmp__(other).__gt__(0)
|
|
27
24
|
|
|
28
25
|
@setdoc.basic
|
|
29
26
|
def __le__(self: Self, other: Any) -> Any:
|
|
30
|
-
return self.__cmp__(other)
|
|
27
|
+
return self.__cmp__(other).__le__(0)
|
|
31
28
|
|
|
32
29
|
@setdoc.basic
|
|
33
30
|
def __lt__(self: Self, other: Any) -> Any:
|
|
34
|
-
return self.__cmp__(other)
|
|
31
|
+
return self.__cmp__(other).__lt__(0)
|
|
35
32
|
|
|
36
33
|
@setdoc.basic
|
|
37
34
|
def __ne__(self: Self, other: Any) -> Any:
|
|
38
|
-
return self.__cmp__(other)
|
|
35
|
+
return self.__cmp__(other).__ne__(0)
|
|
39
36
|
|
|
40
37
|
func: Callable
|
|
41
38
|
funcs: list[Callable]
|
|
@@ -48,8 +45,6 @@ def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
|
|
|
48
45
|
__ne__,
|
|
49
46
|
]
|
|
50
47
|
for func in funcs:
|
|
51
|
-
if hasattr(cls, func.__name__) and not overwrites:
|
|
52
|
-
continue
|
|
53
48
|
setattr(cls, func.__name__, func)
|
|
54
49
|
try:
|
|
55
50
|
func.__module__ = cls.__module__
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|