cmp3 0.0.0.dev1__py3-none-any.whl → 0.1.0.dev1__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/__init__.py CHANGED
@@ -1,5 +1,2 @@
1
1
  from cmp3.core import *
2
2
  from cmp3.tests import *
3
-
4
- if __name__ == "__main__":
5
- main()
cmp3/core/__init__.py CHANGED
@@ -1,8 +1,60 @@
1
+ from abc import ABC, abstractmethod
2
+ from functools import partial
1
3
  from typing import *
2
4
 
3
- __all__ = ["main"]
5
+ import setdoc
4
6
 
7
+ __all__ = ["Comparable", "comparable"]
5
8
 
6
- def main(args: Optional[Iterable] = None) -> None:
7
- "This function prints 'Hello World!'."
8
- print("Hello World!")
9
+
10
+ def comparable(*, overwrite: Any = False) -> type:
11
+ return partial(update, overwrite=overwrite)
12
+
13
+
14
+ def update(cls: type, /, *, overwrite: Any = False) -> type:
15
+ @setdoc.basic
16
+ def __eq__(self: Self, other: Any) -> bool:
17
+ return self.__cmp__(other) == 0
18
+
19
+ @setdoc.basic
20
+ def __ge__(self: Self, other: Any) -> bool:
21
+ return self.__cmp__(other) >= 0
22
+
23
+ @setdoc.basic
24
+ def __gt__(self: Self, other: Any) -> bool:
25
+ return self.__cmp__(other) > 0
26
+
27
+ @setdoc.basic
28
+ def __le__(self: Self, other: Any) -> bool:
29
+ return self.__cmp__(other) <= 0
30
+
31
+ @setdoc.basic
32
+ def __lt__(self: Self, other: Any) -> bool:
33
+ return self.__cmp__(other) < 0
34
+
35
+ @setdoc.basic
36
+ def __ne__(self: Self, other: Any) -> bool:
37
+ return self.__cmp__(other) != 0
38
+
39
+ func: Callable
40
+ funcs: list[Callable]
41
+ funcs = [
42
+ __eq__,
43
+ __ge__,
44
+ __gt__,
45
+ __le__,
46
+ __lt__,
47
+ __ne__,
48
+ ]
49
+ for func in funcs:
50
+ if overwrite or not hasattr(cls, func.__name__):
51
+ setattr(cls, func.__name__, func)
52
+ return cls
53
+
54
+
55
+ @comparable()
56
+ class Comparable(ABC):
57
+ __slots__ = ()
58
+
59
+ @abstractmethod
60
+ def __cmp__(self: Self, other: Any) -> Any: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmp3
3
- Version: 0.0.0.dev1
3
+ Version: 0.1.0.dev1
4
4
  Summary: This project updates the concept of __cmp__ for python3.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -28,7 +28,7 @@ Project-URL: Download, https://pypi.org/project/cmp3/#files
28
28
  Project-URL: Index, https://pypi.org/project/cmp3/
29
29
  Project-URL: Source, https://github.com/johannes-programming/cmp3/
30
30
  Project-URL: Website, https://cmp3.johannes-programming.online/
31
- Classifier: Development Status :: 2 - Pre-Alpha
31
+ Classifier: Development Status :: 3 - Alpha
32
32
  Classifier: License :: OSI Approved :: MIT License
33
33
  Classifier: Natural Language :: English
34
34
  Classifier: Operating System :: OS Independent
@@ -39,6 +39,7 @@ Classifier: Typing :: Typed
39
39
  Requires-Python: >=3.11
40
40
  Description-Content-Type: text/x-rst
41
41
  License-File: LICENSE.txt
42
+ Requires-Dist: setdoc<2,>=1.2.6
42
43
  Dynamic: license-file
43
44
 
44
45
  ====
@@ -0,0 +1,9 @@
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=5HDIgWBNxEoojOZBRHiCjGK-RX_fpSxXZ2bM7KEFgWs,383
4
+ cmp3/tests/test_1984.py,sha256=_ami0cAP8vU0C8RpQhP1tLWnLFGTaeHlOG5O60RVKv8,222
5
+ cmp3-0.1.0.dev1.dist-info/licenses/LICENSE.txt,sha256=Jb9jm2E2hEO2LqnWwHeHt4cneyCbnZ1SBte0bgb9qoY,1074
6
+ cmp3-0.1.0.dev1.dist-info/METADATA,sha256=9YXZyB6O_hJzzDmZ4vFybz96OrmHOXxbDgZvJSaixKw,2305
7
+ cmp3-0.1.0.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ cmp3-0.1.0.dev1.dist-info/top_level.txt,sha256=FzJWsf0Xj_eeRJuFle30ZFjVZs8ahy7oLhYdWx8YkgA,5
9
+ cmp3-0.1.0.dev1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- cmp3/__init__.py,sha256=zkxm2qU9kA37RhIrKHPIZUnJlo-I7V4uVKyy8mNFbsY,88
2
- cmp3/core/__init__.py,sha256=Tr3CwIPY695IbF4DrKHrDes1AKd_iJgddUP46jxKHSw,163
3
- cmp3/tests/__init__.py,sha256=5HDIgWBNxEoojOZBRHiCjGK-RX_fpSxXZ2bM7KEFgWs,383
4
- cmp3/tests/test_1984.py,sha256=_ami0cAP8vU0C8RpQhP1tLWnLFGTaeHlOG5O60RVKv8,222
5
- cmp3-0.0.0.dev1.dist-info/licenses/LICENSE.txt,sha256=Jb9jm2E2hEO2LqnWwHeHt4cneyCbnZ1SBte0bgb9qoY,1074
6
- cmp3-0.0.0.dev1.dist-info/METADATA,sha256=rjtleRsnBp-i8xNcRDCO9CsrumvPDh8DNMeNPa79VCY,2277
7
- cmp3-0.0.0.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- cmp3-0.0.0.dev1.dist-info/top_level.txt,sha256=FzJWsf0Xj_eeRJuFle30ZFjVZs8ahy7oLhYdWx8YkgA,5
9
- cmp3-0.0.0.dev1.dist-info/RECORD,,