From: Mike Bayer Date: Fri, 28 Nov 2025 16:48:22 +0000 (-0500) Subject: happy mypy day X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0260f7e58bcc7574c6b33bbbcc7f511a9e5eba07;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git happy mypy day Change-Id: Ic72aeea508e73344927692f62332b2b62a8cbdea --- diff --git a/lib/sqlalchemy/engine/_processors_cy.py b/lib/sqlalchemy/engine/_processors_cy.py index 2d9cbab0bc..5da3e3c941 100644 --- a/lib/sqlalchemy/engine/_processors_cy.py +++ b/lib/sqlalchemy/engine/_processors_cy.py @@ -4,7 +4,7 @@ # # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php -# mypy: disable-error-code="misc" +# mypy: disable-error-code="misc, untyped-decorator" from __future__ import annotations from datetime import date as date_cls diff --git a/lib/sqlalchemy/engine/_row_cy.py b/lib/sqlalchemy/engine/_row_cy.py index 29d8f6548c..320bba11cf 100644 --- a/lib/sqlalchemy/engine/_row_cy.py +++ b/lib/sqlalchemy/engine/_row_cy.py @@ -6,6 +6,7 @@ # the MIT License: https://www.opensource.org/licenses/mit-license.php # mypy: disable-error-code="misc,no-redef,valid-type,no-untyped-call" # mypy: disable-error-code="index,no-any-return,arg-type,assignment" +# mypy: disable-error-code="untyped-decorator" from __future__ import annotations from typing import Any diff --git a/lib/sqlalchemy/engine/_util_cy.py b/lib/sqlalchemy/engine/_util_cy.py index dd56c65d2a..b9f08bb0e2 100644 --- a/lib/sqlalchemy/engine/_util_cy.py +++ b/lib/sqlalchemy/engine/_util_cy.py @@ -4,7 +4,7 @@ # # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php -# mypy: disable-error-code="misc, type-arg" +# mypy: disable-error-code="misc, type-arg, untyped-decorator" from __future__ import annotations from collections.abc import Mapping diff --git a/lib/sqlalchemy/engine/row.py b/lib/sqlalchemy/engine/row.py index 0744569f83..14ed442ab1 100644 --- a/lib/sqlalchemy/engine/row.py +++ b/lib/sqlalchemy/engine/row.py @@ -43,7 +43,7 @@ else: _Ts = TypeVarTuple("_Ts") -class Row(BaseRow, _RowBase[Unpack[_Ts]], Generic[Unpack[_Ts]]): +class Row(BaseRow, _RowBase[Unpack[_Ts]], Generic[Unpack[_Ts]]): # type: ignore[misc] # noqa: E501 """Represent a single result row. The :class:`.Row` object represents a row of a database result. It is diff --git a/lib/sqlalchemy/orm/mapped_collection.py b/lib/sqlalchemy/orm/mapped_collection.py index a5885fc9d0..a3e2e9b34a 100644 --- a/lib/sqlalchemy/orm/mapped_collection.py +++ b/lib/sqlalchemy/orm/mapped_collection.py @@ -443,8 +443,8 @@ class KeyFuncDict(Dict[_KT, _VT]): f"parameter on the mapped collection factory." ) - @collection.appender # type: ignore[misc] - @collection.internally_instrumented # type: ignore[misc] + @collection.appender # type: ignore[untyped-decorator] + @collection.internally_instrumented # type: ignore[untyped-decorator] def set( self, value: _KT, @@ -472,8 +472,8 @@ class KeyFuncDict(Dict[_KT, _VT]): self.__setitem__(key, value, _sa_initiator) # type: ignore[call-arg] - @collection.remover # type: ignore[misc] - @collection.internally_instrumented # type: ignore[misc] + @collection.remover # type: ignore[untyped-decorator] + @collection.internally_instrumented # type: ignore[untyped-decorator] def remove( self, value: _KT, diff --git a/lib/sqlalchemy/sql/_util_cy.py b/lib/sqlalchemy/sql/_util_cy.py index ddb8680196..d4ae4669d6 100644 --- a/lib/sqlalchemy/sql/_util_cy.py +++ b/lib/sqlalchemy/sql/_util_cy.py @@ -4,6 +4,7 @@ # # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php +# mypy: disable-error-code="untyped-decorator" from __future__ import annotations @@ -94,8 +95,8 @@ class anon_map(Dict[_AM_KEY, _AM_VALUE]): else: _index: int = 0 # type: ignore[no-redef] - @cython.cfunc # type:ignore[misc] - @cython.inline # type:ignore[misc] + @cython.cfunc + @cython.inline def _add_missing(self: anon_map, key: _AM_KEY, /) -> int: val: int = self._index self._index += 1 diff --git a/lib/sqlalchemy/util/_collections_cy.py b/lib/sqlalchemy/util/_collections_cy.py index 65c3b5a684..d823ed4b96 100644 --- a/lib/sqlalchemy/util/_collections_cy.py +++ b/lib/sqlalchemy/util/_collections_cy.py @@ -5,6 +5,7 @@ # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php # mypy: disable-error-code="misc, no-any-return, no-untyped-def, override" +# mypy: disable-error-code="untyped-decorator" from __future__ import annotations diff --git a/lib/sqlalchemy/util/_immutabledict_cy.py b/lib/sqlalchemy/util/_immutabledict_cy.py index 5eb018fbdb..9a32f19a76 100644 --- a/lib/sqlalchemy/util/_immutabledict_cy.py +++ b/lib/sqlalchemy/util/_immutabledict_cy.py @@ -4,7 +4,7 @@ # # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php -# mypy: disable-error-code="misc, arg-type" +# mypy: disable-error-code="misc, arg-type, untyped-decorator" from __future__ import annotations from typing import Any diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index a8313d08e1..7bd293d40c 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -75,7 +75,7 @@ if compat.py314: return None # this is ported from py3.13.0a7 - _BASE_GET_ANNOTATIONS = type.__dict__["__annotations__"].__get__ # type: ignore # noqa: E501 + _BASE_GET_ANNOTATIONS = type.__dict__["__annotations__"].__get__ def _get_dunder_annotations(obj): if isinstance(obj, type): diff --git a/pyproject.toml b/pyproject.toml index 16ce68e514..26ac357af1 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.7", + "mypy >= 1.19", "types-greenlet >= 2", ] mssql = ["pyodbc"] @@ -190,7 +190,7 @@ lint = [ mypy = [ {include-group = "tests-greenlet"}, - "mypy>=1.16.0", + "sqlalchemy[mypy]", "nox", # because we check noxfile.py "pytest>8,<10", # alembic/testing imports pytest "types-greenlet",