Created
March 9, 2025 20:40
-
-
Save mypy-play/dfe06f06e69d157317a667311aa75952 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 typing import TypeVar, Generic, ClassVar, Self | |
T = TypeVar("T", bound="BaseModel") | |
class BaseModel: | |
_meta: "ClassVar[Meta[Self]]" | |
class Meta(Generic[T]): | |
def __init__(self, model: type[T]) -> None: | |
self.model = model | |
@classmethod | |
def __init_subclass__(cls) -> None: | |
cls._meta = cls.Meta(cls) | |
reveal_type(BaseModel._meta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment