mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Fix typo in test dir name + update examples
This commit is contained in:
@@ -5,7 +5,7 @@ class A:
|
|||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
# BAD: Should return NotImplemented instead of raising
|
# BAD: Should return NotImplemented instead of raising
|
||||||
if not isinstance(other,A):
|
if not isinstance(other,A):
|
||||||
raise TypeError(f"Cannot add A to {other.__type__}")
|
raise TypeError(f"Cannot add A to {other.__class__}")
|
||||||
return A(self.a + other.a)
|
return A(self.a + other.a)
|
||||||
|
|
||||||
class B:
|
class B:
|
||||||
@@ -13,7 +13,7 @@ class B:
|
|||||||
self.a = a
|
self.a = a
|
||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
# GOOD: Returning NotImplemented allows for other classes to support adding do B.
|
# GOOD: Returning NotImplemented allows for the operation to fallback to other implementations to allow other classes to support adding to B.
|
||||||
if not isinstance(other,B):
|
if not isinstance(other,B):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return B(self.a + other.a)
|
return B(self.a + other.a)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class D:
|
class D:
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
# BAD: Use `__hash__ = None` instead.
|
# BAD: Use `__hash__ = None` instead.
|
||||||
raise NotImplementedError(f"{self.__type__} is unhashable.")
|
raise NotImplementedError(f"{self.__class__} is unhashable.")
|
||||||
Reference in New Issue
Block a user