]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
qualify mypy1.4 update for python 3.9, 3.10 +
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 Jun 2023 18:59:21 +0000 (14:59 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 Jun 2023 19:04:52 +0000 (15:04 -0400)
in I68084199858e9da901641d6036780437bcf5f2d6 we added a mypy1.4
check to check for new-style type messages.  mypy only
does lowercase types on python 3.9 and above, OR syntax on 3.10
and above.  qualify these both

Change-Id: Ic1ee12927ae02c1936d1c2905db28b587c7fece7
(cherry picked from commit cb39c0109ef5167de3a7a682cc553480172dac82)

test/ext/mypy/test_mypy_plugin_py3k.py

index be80043ca88ca30de1b9dd2e460d892c240ae74d..a92aee1e7123e2f02cfb61b66c4bc7140cf9e208 100644 (file)
@@ -5,6 +5,7 @@ import sys
 import tempfile
 
 from sqlalchemy import testing
+from sqlalchemy import util
 from sqlalchemy.testing import config
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
@@ -195,7 +196,10 @@ class MypyPluginTest(fixtures.TestBase):
                     expected_msg = m.group(2)
                     expected_msg = re.sub(r"# noqa[:]? ?.*", "", m.group(2))
 
-                    if mypy_14:
+                    if mypy_14 and util.py39:
+                        # use_lowercase_names, py39 and above
+                        # https://github.com/python/mypy/blob/304997bfb85200fb521ac727ee0ce3e6085e5278/mypy/options.py#L363  # noqa: E501
+
                         # skip first character which could be capitalized
                         # "List item x not found" type of message
                         expected_msg = expected_msg[0] + re.sub(
@@ -204,6 +208,9 @@ class MypyPluginTest(fixtures.TestBase):
                             expected_msg[1:],
                         )
 
+                    if mypy_14 and util.py310:
+                        # use_or_syntax, py310 and above
+                        # https://github.com/python/mypy/blob/304997bfb85200fb521ac727ee0ce3e6085e5278/mypy/options.py#L368  # noqa: E501
                         expected_msg = re.sub(
                             r"Optional\[(.*?)\]",
                             lambda m: f"{m.group(1)} | None",