Skip to content

Instantly share code, notes, and snippets.

@jhbuhrman
Created September 7, 2018 13:07
Show Gist options
  • Save jhbuhrman/02fa7bc927c8358b47ee3ec3749a2343 to your computer and use it in GitHub Desktop.
Save jhbuhrman/02fa7bc927c8358b47ee3ec3749a2343 to your computer and use it in GitHub Desktop.
Demonstrating mypy false positive (as of mypy 0.620)
class SimpleClass:
some_int: int
some_str: str
def __init__(self, some_int: int, some_str: str) -> None:
self.some_int = some_int
self.some_str = some_str
def __repr__(self) -> str:
return (f'{self.__class__.__qualname__}'
f'(some_int={self.some_int!r}, some_str={self.some_str!r})')
def __eq__(self, o: object) -> bool:
return (self.__class__ == o.__class__
and (self.some_int, self.some_str) == (o.some_int, o.some_str))
sc_1 = SimpleClass(42, "foo")
sc_2 = SimpleClass(42, "foo")
assert sc_1 == sc_2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment