commit:     c77c20efdba79abf30ccb2621d9344a0250131f9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 19 18:02:58 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 19 18:07:27 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c77c20ef

remove some usage of snakeoil.klass.inject_richcmp_methods_from_cmp

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/fs/fs.py          |  8 ++++----
 tests/package/test_mutated.py | 15 ++++++---------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/pkgcore/fs/fs.py b/src/pkgcore/fs/fs.py
index 2554dc00..1abec12d 100644
--- a/src/pkgcore/fs/fs.py
+++ b/src/pkgcore/fs/fs.py
@@ -4,6 +4,7 @@ filesystem entry abstractions
 
 import fnmatch
 import stat
+from functools import total_ordering
 from os.path import abspath, basename, dirname, join as pjoin, normpath, 
realpath
 from os.path import sep as path_seperator
 
@@ -49,6 +50,7 @@ def gen_doc_additions(init, slots):
     )
 
 
+@total_ordering
 class fsBase(immutable.Simple):
     """base class, all extensions must derive from this class"""
 
@@ -62,8 +64,6 @@ class fsBase(immutable.Simple):
         if x.startswith("is") and x.islower() and not x.endswith("fs_obj")
     )
 
-    klass.inject_richcmp_methods_from_cmp(locals())
-
     def __init__(self, location, strict=True, **d):
         d["location"] = normpath(location)
 
@@ -129,8 +129,8 @@ class fsBase(immutable.Simple):
     def fnmatch(self, pattern):
         return fnmatch.fnmatch(self.location, pattern)
 
-    def __cmp__(self, other):
-        return cmp(self.location, other.location)
+    def __lt__(self, other):
+        return self.location < other.location
 
     def __str__(self):
         return self.location

diff --git a/tests/package/test_mutated.py b/tests/package/test_mutated.py
index 32c0a3fd..50b71885 100644
--- a/tests/package/test_mutated.py
+++ b/tests/package/test_mutated.py
@@ -1,16 +1,15 @@
-from functools import partial
+from functools import partial, total_ordering
 
 import pytest
 from pkgcore.package.base import base, dynamic_getattr_dict
 from pkgcore.package.mutated import MutatedPkg
-from snakeoil.compatibility import cmp
-from snakeoil.klass import inject_richcmp_methods_from_cmp
 
 
 def passthru(val, self):
     return val
 
 
+@total_ordering
 class FakePkg(base):
     # XXX why isn't this using existing classes?
     __slotting_intentionally_disabled__ = True
@@ -25,10 +24,8 @@ class FakePkg(base):
     __setattr__ = object.__setattr__
     __getattr__ = dynamic_getattr_dict
 
-    def __cmp__(self, other):
-        return cmp(self.ver, other.ver)
-
-    inject_richcmp_methods_from_cmp(locals())
+    def __lt__(self, other):
+        return self.ver < other.ver
 
 
 class TestMutatedPkg:
@@ -48,8 +45,8 @@ class TestMutatedPkg:
         mpkg2 = MutatedPkg(pkg2, {})
 
         for lpkg in (pkg1, mpkg1):
-            assert cmp(lpkg, mpkg2) < 0
-            assert cmp(mpkg2, lpkg) > 0
+            assert lpkg < mpkg2
+            assert mpkg2 > lpkg
         assert mpkg1 == mpkg1
         assert pkg1 == mpkg1
 

Reply via email to