From: Mike Bayer Date: Wed, 1 Apr 2026 18:31:21 +0000 (-0400) Subject: update for mypy 1.20.0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a54490c9d4dece8dffdd35feb9bf96486661ac0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git update for mypy 1.20.0 Change-Id: I95f72b8a1818b79d01d26531202199f24fe3b808 --- diff --git a/examples/generic_associations/table_per_related.py b/examples/generic_associations/table_per_related.py index bd3311d844..f84d89e0fe 100644 --- a/examples/generic_associations/table_per_related.py +++ b/examples/generic_associations/table_per_related.py @@ -20,6 +20,7 @@ is completely automated. from __future__ import annotations from typing import Any +from typing import ClassVar from typing import TYPE_CHECKING from sqlalchemy import create_engine @@ -92,6 +93,8 @@ class HasAddresses: """ + Address: ClassVar[type] + @declared_attr def addresses(cls: type[Any]) -> Mapped[list[AddressWithParent]]: cls.Address = type( diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py index f0137bc22f..f0efee6b76 100644 --- a/lib/sqlalchemy/ext/hybrid.py +++ b/lib/sqlalchemy/ext/hybrid.py @@ -1755,7 +1755,7 @@ class hybrid_property(interfaces.InspectionAttrInfo, ORMDescriptor[_T]): name = self.__name__ break else: - name = attributes._UNKNOWN_ATTR_KEY # type: ignore[assignment] + name = attributes._UNKNOWN_ATTR_KEY # type: ignore[assignment,unused-ignore] # noqa: E501 return cast( "_HybridClassLevelAccessor[_T]", diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 535eb58b93..c2b0344d89 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -1034,7 +1034,7 @@ class MutableSet(Mutable, Set[_T]): self.symmetric_difference_update(other) return self - def __isub__(self, other: AbstractSet[object]) -> MutableSet[_T]: # type: ignore[misc] # noqa: E501 + def __isub__(self, other: AbstractSet[object]) -> MutableSet[_T]: # type: ignore[misc,unused-ignore] # noqa: E501 self.difference_update(other) return self @@ -1046,7 +1046,7 @@ class MutableSet(Mutable, Set[_T]): set.remove(self, elem) self.changed() - def discard(self, elem: _T) -> None: + def discard(self, elem: _T) -> None: # type: ignore[override,unused-ignore] # noqa: E501 set.discard(self, elem) self.changed() diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 5273aa6e7f..b8781d00ba 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -4756,6 +4756,8 @@ class SQLCompiler(Compiled): "_label_select_column is only relevant within " "the columns clause of a SELECT or RETURNING" ) + result_expr: elements.Label[Any] | _CompileLabel + if isinstance(column, elements.Label): if col_expr is not column: result_expr = _CompileLabel( diff --git a/lib/sqlalchemy/util/_immutabledict_cy.py b/lib/sqlalchemy/util/_immutabledict_cy.py index 2d556b23f8..e4ea842ec0 100644 --- a/lib/sqlalchemy/util/_immutabledict_cy.py +++ b/lib/sqlalchemy/util/_immutabledict_cy.py @@ -229,12 +229,12 @@ class immutabledict(Dict[_KT, _VT]): self, __value: Mapping[_KT, _VT], / ) -> immutabledict[_KT, _VT]: return immutabledict( - dict.__or__(self, __value), # type: ignore[call-overload] + dict.__or__(self, __value), # type: ignore[call-overload,operator,unused-ignore] # noqa: E501 ) def __ror__( # type: ignore[override] self, __value: Mapping[_KT, _VT], / ) -> immutabledict[_KT, _VT]: return immutabledict( - dict.__ror__(self, __value), # type: ignore[call-overload] + dict.__ror__(self, __value), # type: ignore[call-overload,operator,unused-ignore] # noqa: E501 ) diff --git a/pyproject.toml b/pyproject.toml index f2d9d61ca5..9cc90ee099 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ Discussions = "https://github.com/sqlalchemy/sqlalchemy/discussions" [project.optional-dependencies] asyncio = ["greenlet>=1"] mypy = [ - "mypy >= 1.19", + "mypy >= 1.20", "types-greenlet >= 2", ] mssql = ["pyodbc"]