Created
June 10, 2026 14:08
-
-
Save mypy-play/9cbb94b203fd103f1c9ef2b812121e3a to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or 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 ( | |
| Generic, | |
| Literal, | |
| TypeAlias, | |
| overload, | |
| ) | |
| from typing_extensions import ( | |
| TypeVar, | |
| ) | |
| Storage: TypeAlias = Literal["python", "pyarrow"] | |
| StorageT = TypeVar("StorageT", bound=Storage) | |
| _StorageT = TypeVar("_StorageT", bound=Storage | None, default=None) | |
| class _StringDtypeStorageDescriptor: | |
| @overload | |
| def __get__( | |
| self, instance: StringDtype[None], owner: type[StringDtype[None]] | |
| ) -> Storage: ... | |
| @overload | |
| def __get__( | |
| self, instance: StringDtype[StorageT], owner: type[StringDtype[StorageT]] | |
| ) -> StorageT: ... | |
| class StringDtype(Generic[_StorageT]): | |
| storage = _StringDtypeStorageDescriptor() | |
| reveal_type(StringDtype[Literal["python"]]().storage) # mypy, pyright, ty: Literal["python"], pyrefly: error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment