Skip to content

Instantly share code, notes, and snippets.

@pranithan-kang
Created March 29, 2024 07:31
Show Gist options
  • Save pranithan-kang/e9492ef7b78d9983274c1c84fe5a0396 to your computer and use it in GitHub Desktop.
Save pranithan-kang/e9492ef7b78d9983274c1c84fe5a0396 to your computer and use it in GitHub Desktop.
generic type experimental
# "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