MCPcopy Index your code
hub / github.com/RustPython/RustPython / total_ordering

Function total_ordering

Lib/functools.py:188–199  ·  view source on GitHub ↗

Class decorator that fills in missing ordering methods

(cls)

Source from the content-addressed store, hash-verified

186}
187
188def total_ordering(cls):
189 """Class decorator that fills in missing ordering methods"""
190 # Find user-defined comparisons (not those inherited from object).
191 roots = {op for op in _convert if getattr(cls, op, None) is not getattr(object, op, None)}
192 if not roots:
193 raise ValueError('must define at least one ordering operation: < > <= >=')
194 root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
195 for opname, opfunc in _convert[root]:
196 if opname not in roots:
197 opfunc.__name__ = opname
198 setattr(cls, opname, opfunc)
199 return cls
200
201
202################################################################################

Callers

nothing calls this directly

Calls 3

getattrFunction · 0.85
maxFunction · 0.85
setattrFunction · 0.85

Tested by

no test coverage detected