Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 9, 2024 00:44
Show Gist options
  • Save mypy-play/e272e1c05d4170c4a2678e57782de202 to your computer and use it in GitHub Desktop.
Save mypy-play/e272e1c05d4170c4a2678e57782de202 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Literal, override
class Foo:
@override
def __eq__(self, value: object, /) -> bool:
return True
def fun(a: Foo | Literal["a"]) -> None:
if a == "a":
reveal_type(a) # Foo | Literal['a']
else:
reveal_type(a) # Foo | Literal['a']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment