mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +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):
|
||||
# BAD: Should return NotImplemented instead of raising
|
||||
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)
|
||||
|
||||
class B:
|
||||
@@ -13,7 +13,7 @@ class B:
|
||||
self.a = a
|
||||
|
||||
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):
|
||||
return NotImplemented
|
||||
return B(self.a + other.a)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class D:
|
||||
def __hash__(self):
|
||||
# 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