Created
July 10, 2025 22:14
-
-
Save mypy-play/b843af1de98a6c95b0baf2363220bc9b to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or 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 overload | |
class A[T]: ... | |
class B[T: (int, str)](A[T]): | |
@overload | |
def __new__(cls: type[B[int]]) -> B[int]: ... | |
@overload | |
def __new__(cls: type[B[str]]) -> B[str]: ... | |
def __new__(cls): raise NotImplementedError | |
def foo(x: A[str]) -> None: | |
if isinstance(x, B): | |
reveal_type(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment