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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmp3
3
- Version: 0.3.0
3
+ Version: 0.4.0
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)
@@ -26,7 +26,7 @@ keywords = []
26
26
  name = "cmp3"
27
27
  readme = "README.rst"
28
28
  requires-python = ">=3.11"
29
- version = "0.3.0"
29
+ version = "0.4.0"
30
30
 
31
31
  [project.license]
32
32
  file = "LICENSE.txt"
@@ -4,38 +4,35 @@ from typing import *
4
4
 
5
5
  import setdoc
6
6
 
7
- __all__ = ["Comparable", "comparable", "update_rich_cmp"]
7
+ __all__ = ["Comparable", "comparable"]
8
8
 
9
9
 
10
- def comparable(*, overwrites: Any = False) -> partial:
11
- "This function returns a decorator."
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) == 0
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) >= 0
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) > 0
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) <= 0
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) < 0
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) != 0
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__
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmp3
3
- Version: 0.3.0
3
+ Version: 0.4.0
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)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes