cmp3 0.3.1__tar.gz → 0.5.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.1
3
+ Version: 0.5.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.1"
29
+ version = "0.5.0"
30
30
 
31
31
  [project.license]
32
32
  file = "LICENSE.txt"
@@ -1,18 +1,14 @@
1
1
  from abc import ABC, abstractmethod
2
- from functools import partial
3
2
  from typing import *
4
3
 
5
4
  import setdoc
6
5
 
7
- __all__ = ["Comparable", "comparable", "update_rich_cmp"]
6
+ __all__ = ["CmpABC", "cmpDeco"]
8
7
 
9
8
 
10
- def comparable(*, overwrites: Any = False) -> partial:
11
- "This function returns a decorator."
12
- return partial(update_rich_cmp, overwrites=overwrites)
9
+ def cmpDeco(cls: type, /) -> type:
10
+ "This decorator enforces the use of __cmp__ upon a class."
13
11
 
14
-
15
- def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
16
12
  @setdoc.basic
17
13
  def __eq__(self: Self, other: Any) -> Any:
18
14
  return self.__cmp__(other).__eq__(0)
@@ -38,18 +34,16 @@ def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
38
34
  return self.__cmp__(other).__ne__(0)
39
35
 
40
36
  func: Callable
41
- funcs: list[Callable]
42
- funcs = [
37
+ funcs: tuple[Callable, ...]
38
+ funcs = (
43
39
  __eq__,
44
40
  __ge__,
45
41
  __gt__,
46
42
  __le__,
47
43
  __lt__,
48
44
  __ne__,
49
- ]
45
+ )
50
46
  for func in funcs:
51
- if hasattr(cls, func.__name__) and not overwrites:
52
- continue
53
47
  setattr(cls, func.__name__, func)
54
48
  try:
55
49
  func.__module__ = cls.__module__
@@ -62,8 +56,8 @@ def update_rich_cmp(cls: type, /, *, overwrites: Any = False) -> type:
62
56
  return cls
63
57
 
64
58
 
65
- @comparable()
66
- class Comparable(ABC):
59
+ @comparable
60
+ class CmpABC(ABC):
67
61
  __slots__ = ()
68
62
 
69
63
  @abstractmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmp3
3
- Version: 0.3.1
3
+ Version: 0.5.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