summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-04-07 12:37:23 -0400
committermike bayer <mike_mp@zzzcomputing.com>2022-04-12 02:09:50 +0000
commitaa9cd878e8249a4a758c7f968e929e92fede42a5 (patch)
tree1be1c9dc24dd247a150be55d65bfc56ebaf111bc /lib/sqlalchemy/sql
parent98eae4e181cb2d1bbc67ec834bfad29dcba7f461 (diff)
downloadsqlalchemy-aa9cd878e8249a4a758c7f968e929e92fede42a5.tar.gz
pep-484: session, instancestate, etc
Also adds some fixes to annotation-based mapping that have come up, as well as starts to add more pep-484 test cases Change-Id: Ia722bbbc7967a11b23b66c8084eb61df9d233fee
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/_typing.py9
-rw-r--r--lib/sqlalchemy/sql/base.py8
-rw-r--r--lib/sqlalchemy/sql/coercions.py2
-rw-r--r--lib/sqlalchemy/sql/selectable.py6
4 files changed, 18 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/_typing.py b/lib/sqlalchemy/sql/_typing.py
index bc1e0672c..7e3a1c4e8 100644
--- a/lib/sqlalchemy/sql/_typing.py
+++ b/lib/sqlalchemy/sql/_typing.py
@@ -7,6 +7,7 @@ from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union
+from sqlalchemy.sql.base import Executable
from . import roles
from .. import util
from ..inspection import Inspectable
@@ -183,10 +184,14 @@ if TYPE_CHECKING:
def is_table_value_type(t: TypeEngine[Any]) -> TypeGuard[TableValueType]:
...
- def is_select_base(t: ReturnsRows) -> TypeGuard[SelectBase]:
+ def is_select_base(
+ t: Union[Executable, ReturnsRows]
+ ) -> TypeGuard[SelectBase]:
...
- def is_select_statement(t: ReturnsRows) -> TypeGuard[Select]:
+ def is_select_statement(
+ t: Union[Executable, ReturnsRows]
+ ) -> TypeGuard[Select]:
...
def is_table(t: FromClause) -> TypeGuard[TableClause]:
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py
index 7fb9c2602..ccd5e8c40 100644
--- a/lib/sqlalchemy/sql/base.py
+++ b/lib/sqlalchemy/sql/base.py
@@ -648,7 +648,9 @@ class CompileState:
return None
@classmethod
- def _get_plugin_class_for_plugin(cls, statement, plugin_name):
+ def _get_plugin_class_for_plugin(
+ cls, statement: Executable, plugin_name: str
+ ) -> Optional[Type[CompileState]]:
try:
return cls.plugins[
(plugin_name, statement._effective_plugin_target)
@@ -790,7 +792,7 @@ class Options(metaclass=_MetaOptions):
)
@classmethod
- def isinstance(cls, klass):
+ def isinstance(cls, klass: Type[Any]) -> bool:
return issubclass(cls, klass)
@hybridmethod
@@ -912,6 +914,8 @@ class ExecutableOption(HasCopyInternals):
_is_has_cache_key = False
+ _is_core = True
+
def _clone(self, **kw):
"""Create a shallow copy of this ExecutableOption."""
c = self.__class__.__new__(self.__class__)
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py
index 4c71ca38b..623bb0be2 100644
--- a/lib/sqlalchemy/sql/coercions.py
+++ b/lib/sqlalchemy/sql/coercions.py
@@ -114,7 +114,7 @@ def _deep_is_literal(element):
schema.SchemaEventTarget,
HasCacheKey,
Options,
- util.langhelpers._symbol,
+ util.langhelpers.symbol,
),
)
and not hasattr(element, "__clause_element__")
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index d7cc32733..99a6baa89 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -3037,7 +3037,9 @@ class ForUpdateArg(ClauseElement):
skip_locked: bool
@classmethod
- def _from_argument(cls, with_for_update):
+ def _from_argument(
+ cls, with_for_update: Union[ForUpdateArg, None, bool, Dict[str, Any]]
+ ) -> Optional[ForUpdateArg]:
if isinstance(with_for_update, ForUpdateArg):
return with_for_update
elif with_for_update in (None, False):
@@ -3045,7 +3047,7 @@ class ForUpdateArg(ClauseElement):
elif with_for_update is True:
return ForUpdateArg()
else:
- return ForUpdateArg(**with_for_update)
+ return ForUpdateArg(**cast("Dict[str, Any]", with_for_update))
def __eq__(self, other):
return (