mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Fix qldoc errors + typos
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user