Fix typo in test dir name + update examples

This commit is contained in:
Joe Farebrother
2025-07-25 13:15:46 +01:00
parent 958fddb638
commit c0da9c407e
5 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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.")