summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2023-01-31 22:01:34 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2023-01-31 22:01:34 +0000
commit8b41e839699c52e908ba3fff5b572ca82511a85f (patch)
tree7fc5364a13292669800d049f1e57dd18d9fb4e1e /lib/sqlalchemy
parenta21c715b7a89b0619db0d2d5b31617d17b25a27a (diff)
parent961f0762304db1db931d399e3b0b35cd99a4b21d (diff)
downloadsqlalchemy-8b41e839699c52e908ba3fff5b572ca82511a85f.tar.gz
Merge "Unify doc typing" into main
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py3
-rw-r--r--lib/sqlalchemy/ext/associationproxy.py21
-rw-r--r--lib/sqlalchemy/ext/asyncio/base.py5
-rw-r--r--lib/sqlalchemy/ext/automap.py16
-rw-r--r--lib/sqlalchemy/ext/mutable.py4
-rw-r--r--lib/sqlalchemy/orm/decl_api.py2
6 files changed, 25 insertions, 26 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 009297583..d7e6634b3 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1428,6 +1428,7 @@ import re
from typing import Any
from typing import List
from typing import Optional
+from typing import Tuple
from . import array as _array
from . import hstore as _hstore
@@ -3350,7 +3351,7 @@ class PGDialect(default.DefaultDialect):
else:
return False, {}
- def _kind_to_relkinds(self, kind: ObjectKind) -> tuple[str, ...]:
+ def _kind_to_relkinds(self, kind: ObjectKind) -> Tuple[str, ...]:
if kind is ObjectKind.ANY:
return pg_catalog.RELKINDS_ALL_TABLE_LIKE
relkinds = ()
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py
index 29ff484b2..24f348bd1 100644
--- a/lib/sqlalchemy/ext/associationproxy.py
+++ b/lib/sqlalchemy/ext/associationproxy.py
@@ -28,6 +28,7 @@ from typing import ItemsView
from typing import Iterable
from typing import Iterator
from typing import KeysView
+from typing import List
from typing import Mapping
from typing import MutableMapping
from typing import MutableSequence
@@ -1552,38 +1553,38 @@ class _AssociationList(_AssociationSingleItem[_T], MutableSequence[_T]):
def __ne__(self, other: object) -> bool:
return list(self) != other
- def __lt__(self, other: list[_T]) -> bool:
+ def __lt__(self, other: List[_T]) -> bool:
return list(self) < other
- def __le__(self, other: list[_T]) -> bool:
+ def __le__(self, other: List[_T]) -> bool:
return list(self) <= other
- def __gt__(self, other: list[_T]) -> bool:
+ def __gt__(self, other: List[_T]) -> bool:
return list(self) > other
- def __ge__(self, other: list[_T]) -> bool:
+ def __ge__(self, other: List[_T]) -> bool:
return list(self) >= other
- def __add__(self, other: list[_T]) -> list[_T]:
+ def __add__(self, other: List[_T]) -> List[_T]:
try:
other = list(other)
except TypeError:
return NotImplemented
return list(self) + other
- def __radd__(self, other: list[_T]) -> list[_T]:
+ def __radd__(self, other: List[_T]) -> List[_T]:
try:
other = list(other)
except TypeError:
return NotImplemented
return other + list(self)
- def __mul__(self, n: SupportsIndex) -> list[_T]:
+ def __mul__(self, n: SupportsIndex) -> List[_T]:
if not isinstance(n, int):
return NotImplemented
return list(self) * n
- def __rmul__(self, n: SupportsIndex) -> list[_T]:
+ def __rmul__(self, n: SupportsIndex) -> List[_T]:
if not isinstance(n, int):
return NotImplemented
return n * list(self)
@@ -1616,7 +1617,7 @@ class _AssociationList(_AssociationSingleItem[_T], MutableSequence[_T]):
ls = list(self)
return ls.index(value, *arg)
- def copy(self) -> list[_T]:
+ def copy(self) -> List[_T]:
return list(self)
def __repr__(self) -> str:
@@ -1776,7 +1777,7 @@ class _AssociationDict(_AssociationCollection[_VT], MutableMapping[_KT, _VT]):
for key in removals:
del self[key]
- def copy(self) -> dict[_KT, _VT]:
+ def copy(self) -> Dict[_KT, _VT]:
return dict(self.items())
def __hash__(self) -> NoReturn:
diff --git a/lib/sqlalchemy/ext/asyncio/base.py b/lib/sqlalchemy/ext/asyncio/base.py
index 394c11263..765ee94a0 100644
--- a/lib/sqlalchemy/ext/asyncio/base.py
+++ b/lib/sqlalchemy/ext/asyncio/base.py
@@ -21,6 +21,7 @@ from typing import Generic
from typing import NoReturn
from typing import Optional
from typing import overload
+from typing import Tuple
from typing import Type
from typing import TypeVar
import weakref
@@ -160,8 +161,8 @@ class GeneratorStartableContext(StartableContext[_T_co]):
def __init__(
self,
func: Callable[..., AsyncIterator[_T_co]],
- args: tuple[Any, ...],
- kwds: dict[str, Any],
+ args: Tuple[Any, ...],
+ kwds: Dict[str, Any],
):
self.gen = func(*args, **kwds) # type: ignore
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py
index 75bfbbc4d..030015284 100644
--- a/lib/sqlalchemy/ext/automap.py
+++ b/lib/sqlalchemy/ext/automap.py
@@ -1232,14 +1232,10 @@ class AutomapBase:
)
}
- many_to_many: list[
- tuple[
- Table,
- Table,
- list[ForeignKeyConstraint],
- Table,
- ]
- ] = []
+ many_to_many: List[
+ Tuple[Table, Table, List[ForeignKeyConstraint], Table]
+ ]
+ many_to_many = []
bookkeeping = cls._sa_automapbase_bookkeeping
metadata_tables = cls.metadata.tables
@@ -1430,7 +1426,7 @@ def _is_many_to_many(
if len(fk_constraints) != 2:
return None, None, None
- cols: list[Column[Any]] = sum(
+ cols: List[Column[Any]] = sum(
[
[fk.parent for fk in fk_constraint.elements]
for fk_constraint in fk_constraints
@@ -1488,7 +1484,7 @@ def _relationships_for_fks(
automap_base, referred_cls, local_cls, constraint
)
- o2m_kws: dict[str, Union[str, bool]] = {}
+ o2m_kws: Dict[str, Union[str, bool]] = {}
nullable = False not in {fk.parent.nullable for fk in fks}
if not nullable:
o2m_kws["cascade"] = "all, delete-orphan"
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py
index 9ba2b5a15..07f357bd6 100644
--- a/lib/sqlalchemy/ext/mutable.py
+++ b/lib/sqlalchemy/ext/mutable.py
@@ -847,7 +847,7 @@ class MutableDict(Mutable, Dict[_KT, _VT]):
else:
return value
- def __getstate__(self) -> dict[_KT, _VT]:
+ def __getstate__(self) -> Dict[_KT, _VT]:
return dict(self)
def __setstate__(
@@ -1051,7 +1051,7 @@ class MutableSet(Mutable, Set[_T]):
else:
return value
- def __getstate__(self) -> set[_T]:
+ def __getstate__(self) -> Set[_T]:
return set(self)
def __setstate__(self, state: Iterable[_T]) -> None:
diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py
index 4f8443833..c36089fde 100644
--- a/lib/sqlalchemy/orm/decl_api.py
+++ b/lib/sqlalchemy/orm/decl_api.py
@@ -383,7 +383,7 @@ class declared_attr(interfaces._MappedAttribute[_T], _declared_attr_common):
type: Mapped[str] = mapped_column(String(50))
@declared_attr.directive
- def __mapper_args__(cls) -> dict[str, Any]:
+ def __mapper_args__(cls) -> Dict[str, Any]:
if cls.__name__ == 'Employee':
return {
"polymorphic_on":cls.type,