Created
March 8, 2025 18:50
-
-
Save mypy-play/eb0368ff186c5e35e136bbc3eba0d98c 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 collections.abc import Callable | |
from enum import Enum | |
from typing import Generic, Protocol, TypeVar, Type, overload | |
T = TypeVar("T", covariant=True) | |
class A(Generic[T]): | |
pass | |
class B: | |
pass | |
AT1 = TypeVar("AT1", bound=A) | |
AT2 = TypeVar("AT2", bound=A) | |
def my_decorator(func: Callable[[AT1], AT2]) -> Callable[[AT1 | B], AT2]: ... | |
@my_decorator | |
def f(a: A[float]) -> A[int]: ... | |
reveal_type(my_decorator) | |
reveal_type(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment