diff --git a/useful_types/experimental.py b/useful_types/experimental.py index 6c4ba37..8f8975b 100644 --- a/useful_types/experimental.py +++ b/useful_types/experimental.py @@ -42,3 +42,11 @@ def __init_subclass__(cls): "Use the @dataclass decorator to create dataclasses, " "rather than subclassing dataclasses.DataclassLike" ) + + +# Based on: https://github.com/python/mypy/issues/8363#issuecomment-2462048345 +class ExactType(Protocol[T]): + @property + def __class__(self, /) -> type[T]: ... + @__class__.setter + def __class__(self, t: type[T], /) -> None: ...