diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-13 13:37:11 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-15 21:38:29 -0400 |
commit | 6acf5d2fca4a988a77481b82662174e8015a6b37 (patch) | |
tree | 73e2868a51b8b7ac46d7b3b7f9562c1d011f6e1b /lib/sqlalchemy/sql/_typing.py | |
parent | 35f82173e04b3209e07fcfc0606a7614108d018e (diff) | |
download | sqlalchemy-6acf5d2fca4a988a77481b82662174e8015a6b37.tar.gz |
pep-484 - SQL column operations
note we are taking out the
ColumnOperartors[SQLCoreOperations] thing; not really clear
why that was needed and at the moment it seems I was likely
confused.
Change-Id: I834b75f9b44f91b97e29f2e1a7b1029bd910e0a1
Diffstat (limited to 'lib/sqlalchemy/sql/_typing.py')
-rw-r--r-- | lib/sqlalchemy/sql/_typing.py | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/_typing.py b/lib/sqlalchemy/sql/_typing.py index 69e4645fa..389f7e8d0 100644 --- a/lib/sqlalchemy/sql/_typing.py +++ b/lib/sqlalchemy/sql/_typing.py @@ -1,14 +1,58 @@ from __future__ import annotations +from typing import Any from typing import Type +from typing import TYPE_CHECKING +from typing import TypeVar from typing import Union from . import roles +from .. import util from ..inspection import Inspectable +if TYPE_CHECKING: + from .elements import quoted_name + from .schema import DefaultGenerator + from .schema import Sequence + from .selectable import FromClause + from .selectable import NamedFromClause + from .selectable import TableClause + from .sqltypes import TupleType + from .type_api import TypeEngine + from ..util.typing import TypeGuard + +_T = TypeVar("_T", bound=Any) + _ColumnsClauseElement = Union[ - roles.ColumnsClauseRole, Type, Inspectable[roles.HasClauseElement] + roles.ColumnsClauseRole, + Type, + Inspectable[roles.HasColumnElementClauseElement], ] _FromClauseElement = Union[ roles.FromClauseRole, Type, Inspectable[roles.HasFromClauseElement] ] + +_ColumnExpression = Union[ + roles.ExpressionElementRole[_T], + Inspectable[roles.HasColumnElementClauseElement], +] + +_PropagateAttrsType = util.immutabledict[str, Any] + +_TypeEngineArgument = Union[Type["TypeEngine[_T]"], "TypeEngine[_T]"] + + +def is_named_from_clause(t: FromClause) -> TypeGuard[NamedFromClause]: + return t.named_with_column + + +def has_schema_attr(t: FromClause) -> TypeGuard[TableClause]: + return hasattr(t, "schema") + + +def is_quoted_name(s: str) -> TypeGuard[quoted_name]: + return hasattr(s, "quote") + + +def is_tuple_type(t: TypeEngine[Any]) -> TypeGuard[TupleType]: + return t._is_tuple_type |