Fix qldoc errors + typos

This commit is contained in:
Joe Farebrother
2025-07-14 14:26:49 +01:00
parent 61af4e4514
commit f784bb0a35
4 changed files with 6 additions and 4 deletions

View File

@@ -14,10 +14,12 @@ then the <code>!=</code> operator will automatically delegate to the <code>__eq_
<p>However, if the <code>__ne__</code> method is defined without a corresponding <code>__eq__</code> method,
the <code>==</code> operator will still default to object identity (equivalent to the <code>is</code> operator), while the <code>!=</code>
operator will use the <code>__ne__</code> method, which may be inconsistent.
</p>
<p>Additionally, if the <code>__ne__</code> method is defined on a superclass, and the subclass defines its own <cde>__eq__</code> method without overriding
<p>Additionally, if the <code>__ne__</code> method is defined on a superclass, and the subclass defines its own <code>__eq__</code> method without overriding
the superclass <code>__ne__</code> method, the <code>!=</code> operator will use this superclass <code>__ne__</code> method, rather than automatically delegating
to <code>__eq__</code>, which may be incorrect.
</p>
</overview>
<recommendation>

View File

@@ -10,7 +10,7 @@ class B:
class C(B):
def __init__(self, b, c):
super().init(b)
super().__init__(b)
self.c = c
# BAD: eq is defined, but != will use superclass ne method, which is not consistent

View File

@@ -2,7 +2,7 @@ class A:
def __init__(self, i):
self.i = i
# BAD: le is not defined, so `A(1) <= A(2) would result in an error.`
# BAD: le is not defined, so `A(1) <= A(2)` would result in an error.
def __lt__(self, other):
return self.i < other.i

View File

@@ -2,7 +2,7 @@ class A:
def __eq__(self, other):
return True
def __hash__(self, other):
def __hash__(self):
return 7
# B is automatically non-hashable - so eq without hash never needs to alert