Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created July 1, 2025 23:52
Show Gist options
  • Save mypy-play/a7bcaf5164231390c6036f3818a63e55 to your computer and use it in GitHub Desktop.
Save mypy-play/a7bcaf5164231390c6036f3818a63e55 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Never, Self, overload
from warnings import deprecated
class MyClass:
def __init__(self: Self, x: int):
self.x = x
@overload
def __eq__(self, other: Self) -> bool: ...
@overload
@deprecated('foo')
def __eq__(self, other: object) -> bool: ...
def __eq__(self, other: object) -> bool: ...
reveal_type(MyClass(5) == 5) # ❌ I want mypy to give an error here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment