diff options
Diffstat (limited to 'lib/sqlalchemy/util/typing.py')
-rw-r--r-- | lib/sqlalchemy/util/typing.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/typing.py b/lib/sqlalchemy/util/typing.py new file mode 100644 index 000000000..801c4a110 --- /dev/null +++ b/lib/sqlalchemy/util/typing.py @@ -0,0 +1,43 @@ +from typing import Any +from typing import Generic +from typing import overload +from typing import Type +from typing import TypeVar + +from . import compat + +if compat.py38: + from typing import Literal + from typing import Protocol + from typing import TypedDict +else: + from typing_extensions import Literal # noqa + from typing_extensions import Protocol # noqa + from typing_extensions import TypedDict # noqa + + +if compat.py311: + from typing import NotRequired # noqa +else: + from typing_extensions import NotRequired # noqa + + +_T = TypeVar("_T") + + +class _TypeToInstance(Generic[_T]): + @overload + def __get__(self, instance: None, owner: Any) -> Type[_T]: + ... + + @overload + def __get__(self, instance: object, owner: Any) -> _T: + ... + + @overload + def __set__(self, instance: None, value: Type[_T]) -> None: + ... + + @overload + def __set__(self, instance: object, value: _T) -> None: + ... |