aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2020-12-14 14:11:43 -0700
committerTim Harder <radhermit@gmail.com>2020-12-14 14:11:43 -0700
commit6ea4bb9fc6dea62c021f5a1c653262ceb0f6bd24 (patch)
tree9fb3ccbb35565476c9bc6c5508634de56d50d30d /src/snakeoil/klass.py
parentcontexts: drop nullcontext since we're >=py38 now (diff)
downloadsnakeoil-6ea4bb9fc6dea62c021f5a1c653262ceb0f6bd24.tar.gz
snakeoil-6ea4bb9fc6dea62c021f5a1c653262ceb0f6bd24.tar.bz2
snakeoil-6ea4bb9fc6dea62c021f5a1c653262ceb0f6bd24.zip
klass: inject_richcmp_methods_from_cmp(): drop inject_always param
Since we're py3k only we always need to inject the methods when this is used.
Diffstat (limited to 'src/snakeoil/klass.py')
-rw-r--r--src/snakeoil/klass.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/snakeoil/klass.py b/src/snakeoil/klass.py
index 92a6b44..c16181d 100644
--- a/src/snakeoil/klass.py
+++ b/src/snakeoil/klass.py
@@ -22,7 +22,7 @@ import inspect
import itertools
from operator import attrgetter
-from . import caching, compatibility
+from . import caching
from .currying import post_curry
@@ -261,7 +261,7 @@ def generic_gt(self, other):
return self.__cmp__(other) > 0
-def inject_richcmp_methods_from_cmp(scope, inject_always=False):
+def inject_richcmp_methods_from_cmp(scope):
"""
class namespace modifier injecting richcmp methods that rely on __cmp__ for py3k
compatibility
@@ -283,7 +283,7 @@ def inject_richcmp_methods_from_cmp(scope, inject_always=False):
... # exist (__cmp__ would be sufficient).
...
... # add the generic rich comparsion methods to the local class namespace
- ... inject_richcmp_methods_from_cmp(locals(), True)
+ ... inject_richcmp_methods_from_cmp(locals())
...
... def __init__(self, a, b):
... self.a, self.b = a, b
@@ -298,12 +298,8 @@ def inject_richcmp_methods_from_cmp(scope, inject_always=False):
>>> assert foo(1, 1).__eq__(foo(1, 1))
:param scope: the modifiable scope of a class namespace to work on
- :param inject_always: normally injection is only done if it's py3k; if True,
- it'll always inject the rich comparison methods
"""
- if not inject_always:
- return
for key, func in (("__lt__", generic_lt), ("__le__", generic_le),
("__eq__", generic_eq), ("__ne__", generic_ne),
("__ge__", generic_ge), ("__gt__", generic_gt)):