Created
May 11, 2024 07:52
-
-
Save mypy-play/624821e5afb466e1953ab2ab51fbdf13 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
import typing as t | |
class C: | |
pass | |
_C = t.TypeVar('_C', bound=C) | |
class A(t.Generic[_C]): | |
def __init__(self, c: type[_C] | None = None) -> None: | |
self._c = c or C | |
@property | |
def c(self) -> type[_C]: | |
return self._c | |
@c.setter | |
def c(self, c: type[_C]) -> None: | |
self._c = c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment