Created
March 29, 2024 07:31
-
-
Save pranithan-kang/e9492ef7b78d9983274c1c84fe5a0396 to your computer and use it in GitHub Desktop.
generic type experimental
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
# "python.analysis.typeCheckingMode": "strict", | |
from typing import Generic, TypeVar | |
T = TypeVar('T') | |
class MyClass(Generic[T]): | |
def run(self, x: T) -> T: | |
return x | |
class ExtendedMyClass(MyClass[int]): | |
def run(self, x: int) -> int: | |
return x | |
class ExtendedInt(int): | |
pass | |
d: dict[type[int], type[MyClass[int]]] = { ExtendedInt: ExtendedMyClass } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment