]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update typing for mypy 1.11; pin plugin to <1.11
authorFederico Caselli <cfederico87@gmail.com>
Mon, 22 Jul 2024 21:17:45 +0000 (23:17 +0200)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 27 Jul 2024 03:38:55 +0000 (23:38 -0400)
(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

doc/build/changelog/unreleased_14/mypy1110.rst [new file with mode: 0644]
doc/build/orm/extensions/mypy.rst
tox.ini

diff --git a/doc/build/changelog/unreleased_14/mypy1110.rst b/doc/build/changelog/unreleased_14/mypy1110.rst
new file mode 100644 (file)
index 0000000..1dc5e0d
--- /dev/null
@@ -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`
index 6c94ae5f7121a813ee2a1833b610a0a22abdde42..0b7e332c53304af3c6a53814949f497d7779cc44 100644 (file)
@@ -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 5372dbb34a76d9e8f83bb9c642bb8bb1a6ec60f9..d8511d3bdad1975399aed5f072d6fb434c30be7f 100644 (file)
--- 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 =