cmp3 0.2.0__py3-none-any.whl → 0.3.1__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.
- cmp3/core/__init__.py +28 -18
- {cmp3-0.2.0.dist-info → cmp3-0.3.1.dist-info}/METADATA +1 -1
- cmp3-0.3.1.dist-info/RECORD +9 -0
- cmp3-0.2.0.dist-info/RECORD +0 -9
- {cmp3-0.2.0.dist-info → cmp3-0.3.1.dist-info}/WHEEL +0 -0
- {cmp3-0.2.0.dist-info → cmp3-0.3.1.dist-info}/licenses/LICENSE.txt +0 -0
- {cmp3-0.2.0.dist-info → cmp3-0.3.1.dist-info}/top_level.txt +0 -0
cmp3/core/__init__.py
CHANGED
|
@@ -4,37 +4,38 @@ from typing import *
|
|
|
4
4
|
|
|
5
5
|
import setdoc
|
|
6
6
|
|
|
7
|
-
__all__ = ["Comparable", "comparable"]
|
|
7
|
+
__all__ = ["Comparable", "comparable", "update_rich_cmp"]
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def comparable(*,
|
|
11
|
-
|
|
10
|
+
def comparable(*, overwrites: Any = False) -> partial:
|
|
11
|
+
"This function returns a decorator."
|
|
12
|
+
return partial(update_rich_cmp, overwrites=overwrites)
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
def
|
|
15
|
+
def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
|
|
15
16
|
@setdoc.basic
|
|
16
|
-
def __eq__(self: Self, other: Any) ->
|
|
17
|
-
return self.__cmp__(other)
|
|
17
|
+
def __eq__(self: Self, other: Any) -> Any:
|
|
18
|
+
return self.__cmp__(other).__eq__(0)
|
|
18
19
|
|
|
19
20
|
@setdoc.basic
|
|
20
|
-
def __ge__(self: Self, other: Any) ->
|
|
21
|
-
return self.__cmp__(other)
|
|
21
|
+
def __ge__(self: Self, other: Any) -> Any:
|
|
22
|
+
return self.__cmp__(other).__ge__(0)
|
|
22
23
|
|
|
23
24
|
@setdoc.basic
|
|
24
|
-
def __gt__(self: Self, other: Any) ->
|
|
25
|
-
return self.__cmp__(other)
|
|
25
|
+
def __gt__(self: Self, other: Any) -> Any:
|
|
26
|
+
return self.__cmp__(other).__gt__(0)
|
|
26
27
|
|
|
27
28
|
@setdoc.basic
|
|
28
|
-
def __le__(self: Self, other: Any) ->
|
|
29
|
-
return self.__cmp__(other)
|
|
29
|
+
def __le__(self: Self, other: Any) -> Any:
|
|
30
|
+
return self.__cmp__(other).__le__(0)
|
|
30
31
|
|
|
31
32
|
@setdoc.basic
|
|
32
|
-
def __lt__(self: Self, other: Any) ->
|
|
33
|
-
return self.__cmp__(other)
|
|
33
|
+
def __lt__(self: Self, other: Any) -> Any:
|
|
34
|
+
return self.__cmp__(other).__lt__(0)
|
|
34
35
|
|
|
35
36
|
@setdoc.basic
|
|
36
|
-
def __ne__(self: Self, other: Any) ->
|
|
37
|
-
return self.__cmp__(other)
|
|
37
|
+
def __ne__(self: Self, other: Any) -> Any:
|
|
38
|
+
return self.__cmp__(other).__ne__(0)
|
|
38
39
|
|
|
39
40
|
func: Callable
|
|
40
41
|
funcs: list[Callable]
|
|
@@ -47,8 +48,17 @@ def update(cls: type, /, *, overwrite: Any = False) -> type:
|
|
|
47
48
|
__ne__,
|
|
48
49
|
]
|
|
49
50
|
for func in funcs:
|
|
50
|
-
if
|
|
51
|
-
|
|
51
|
+
if hasattr(cls, func.__name__) and not overwrites:
|
|
52
|
+
continue
|
|
53
|
+
setattr(cls, func.__name__, func)
|
|
54
|
+
try:
|
|
55
|
+
func.__module__ = cls.__module__
|
|
56
|
+
except AttributeError:
|
|
57
|
+
pass
|
|
58
|
+
try:
|
|
59
|
+
func.__qualname__ = cls.__qualname__
|
|
60
|
+
except AttributeError:
|
|
61
|
+
pass
|
|
52
62
|
return cls
|
|
53
63
|
|
|
54
64
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
cmp3/__init__.py,sha256=hxvwX8wZhft-DkMAoU3xz65RMZib8nPQQiAbxba27iQ,49
|
|
2
|
+
cmp3/core/__init__.py,sha256=6Pn8YmgnSvLZDff_F5itjqbpd3a-FSE5hytxe-uQry0,1725
|
|
3
|
+
cmp3/tests/__init__.py,sha256=HqmxhnTFFqh9Nzl7STV5GeDYqDmhrc9e1TCHssUbC1s,426
|
|
4
|
+
cmp3/tests/test_1984.py,sha256=_ami0cAP8vU0C8RpQhP1tLWnLFGTaeHlOG5O60RVKv8,222
|
|
5
|
+
cmp3-0.3.1.dist-info/licenses/LICENSE.txt,sha256=Jb9jm2E2hEO2LqnWwHeHt4cneyCbnZ1SBte0bgb9qoY,1074
|
|
6
|
+
cmp3-0.3.1.dist-info/METADATA,sha256=X8-00Sc5gEgG9F_lBw1wYDvvpdVC7KpxufedMa0GhVE,2300
|
|
7
|
+
cmp3-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
cmp3-0.3.1.dist-info/top_level.txt,sha256=FzJWsf0Xj_eeRJuFle30ZFjVZs8ahy7oLhYdWx8YkgA,5
|
|
9
|
+
cmp3-0.3.1.dist-info/RECORD,,
|
cmp3-0.2.0.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
cmp3/__init__.py,sha256=hxvwX8wZhft-DkMAoU3xz65RMZib8nPQQiAbxba27iQ,49
|
|
2
|
-
cmp3/core/__init__.py,sha256=SmM-FrPh000RvG-gd3M_XiI_XtlejCLq_bXi3-7PrCQ,1379
|
|
3
|
-
cmp3/tests/__init__.py,sha256=HqmxhnTFFqh9Nzl7STV5GeDYqDmhrc9e1TCHssUbC1s,426
|
|
4
|
-
cmp3/tests/test_1984.py,sha256=_ami0cAP8vU0C8RpQhP1tLWnLFGTaeHlOG5O60RVKv8,222
|
|
5
|
-
cmp3-0.2.0.dist-info/licenses/LICENSE.txt,sha256=Jb9jm2E2hEO2LqnWwHeHt4cneyCbnZ1SBte0bgb9qoY,1074
|
|
6
|
-
cmp3-0.2.0.dist-info/METADATA,sha256=aNj--BEREH2nMvcnYP8y5q4AW7H0GNPOzvgGc_aP4y8,2300
|
|
7
|
-
cmp3-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
cmp3-0.2.0.dist-info/top_level.txt,sha256=FzJWsf0Xj_eeRJuFle30ZFjVZs8ahy7oLhYdWx8YkgA,5
|
|
9
|
-
cmp3-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|