From: Federico Caselli Date: Mon, 22 Jul 2024 21:17:45 +0000 (+0200) Subject: update typing for mypy 1.11; pin plugin to <1.11 X-Git-Tag: rel_1_4_53~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b52230d43d7713bb4ee54174507c1e96990236f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git update typing for mypy 1.11; pin plugin to <1.11 (1.4 specific notes) The legacy mypy plugin is no longer fully functional with the latest series of mypy 1.11.0, as changes in the mypy interpreter are no longer compatible with the approach used by the plugin. If code is dependent on the legacy mypy plugin with sqlalchemy2-stubs, it's recommended to pin mypy to be below the 1.11.0 series. Seek upgrading to the 2.0 series of SQLAlchemy and migrating to the modern type annotations. Change-Id: Ib8fef93ede588430dc0f7ed44ef887649a415821 cherry picked from commit 0741fe45f62f89845b15d7faea209b26a652a174) Change-Id: I61f50539cda851b98178060410fedaa70971d01a --- diff --git a/doc/build/changelog/unreleased_14/mypy1110.rst b/doc/build/changelog/unreleased_14/mypy1110.rst new file mode 100644 index 0000000000..1dc5e0dc3e --- /dev/null +++ b/doc/build/changelog/unreleased_14/mypy1110.rst @@ -0,0 +1,14 @@ +.. change:: + :tags: bug, mypy + :versions: 2.0 + + The deprecated mypy plugin is no longer fully functional with the latest + series of mypy 1.11.0, as changes in the mypy interpreter are no longer + compatible with the approach used by the plugin. If code is dependent on + the mypy plugin with sqlalchemy2-stubs, it's recommended to pin mypy to be + below the 1.11.0 series. Seek upgrading to the 2.0 series of SQLAlchemy + and migrating to the modern type annotations. + + .. seealso:: + + :ref:`mypy_toplevel` diff --git a/doc/build/orm/extensions/mypy.rst b/doc/build/orm/extensions/mypy.rst index 6c94ae5f71..0b7e332c53 100644 --- a/doc/build/orm/extensions/mypy.rst +++ b/doc/build/orm/extensions/mypy.rst @@ -10,7 +10,8 @@ MyPy_ type checking tool. **The SQLAlchemy Mypy Plugin is DEPRECATED, and will be removed possibly as early as the SQLAlchemy 2.1 release. We would urge users to please - migrate away from it ASAP.** + migrate away from it ASAP. The mypy plugin also works only up until + mypy version 1.10.1. version 1.11.0 and greater may not work properly.** This plugin cannot be maintained across constantly changing releases of mypy and its stability going forward CANNOT be guaranteed. @@ -21,7 +22,11 @@ MyPy_ type checking tool. .. topic:: SQLAlchemy Mypy Plugin Status Update - **Updated July 2023** + **Updated July 2024** + + The mypy plugin is supported **only up until mypy 1.10.1, and it will have + issues running with 1.11.0 or greater**. Use with mypy 1.11.0 or greater + may have error conditions which currently cannot be resolved. For SQLAlchemy 2.0, the Mypy plugin continues to work at the level at which it reached in the SQLAlchemy 1.4 release. SQLAlchemy 2.0 however features @@ -168,8 +173,7 @@ following:: ) name: Mapped[Optional[str]] = Mapped._special_method(Column(String)) - def __init__(self, id: Optional[int] = ..., name: Optional[str] = ...) -> None: - ... + def __init__(self, id: Optional[int] = ..., name: Optional[str] = ...) -> None: ... some_user = User(id=5, name="user") diff --git a/tox.ini b/tox.ini index 5372dbb34a..d8511d3bda 100644 --- a/tox.ini +++ b/tox.ini @@ -181,7 +181,7 @@ deps= greenlet != 0.4.17 mock; python_version < '3.3' importlib_metadata; python_version < '3.8' - mypy + mypy >= 1.2.0,<1.11 patch==1.* git+https://github.com/sqlalchemy/sqlalchemy2-stubs commands =