From: Mike Bayer Date: Wed, 21 Jun 2023 18:59:21 +0000 (-0400) Subject: qualify mypy1.4 update for python 3.9, 3.10 + X-Git-Tag: rel_2_0_17~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb39c0109ef5167de3a7a682cc553480172dac82;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git qualify mypy1.4 update for python 3.9, 3.10 + 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 --- diff --git a/test/ext/mypy/test_mypy_plugin_py3k.py b/test/ext/mypy/test_mypy_plugin_py3k.py index 4440a16e45..a9cc1eb336 100644 --- a/test/ext/mypy/test_mypy_plugin_py3k.py +++ b/test/ext/mypy/test_mypy_plugin_py3k.py @@ -9,6 +9,7 @@ from typing import List from typing import Tuple from sqlalchemy import testing +from sqlalchemy import util from sqlalchemy.testing import config from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures @@ -272,7 +273,10 @@ class MypyPluginTest(fixtures.TestBase): is_mypy = is_re = True expected_msg = f'Revealed type is "{expected_msg}"' - 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( @@ -283,6 +287,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",