Created
May 9, 2024 00:43
-
-
Save mypy-play/6d6610dbd1b3a257c93c016593e75d30 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | |
fun(Foo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment