From: Nils Philippsen Date: Thu, 30 Jan 2025 13:10:55 +0000 (-0500) Subject: Skip mypy plugin tests if incompatible or missing X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e5a6cccc600a7995b70af55381f075566dc01a9;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Skip mypy plugin tests if incompatible or missing Fixes: #12287 ### Description This skips Mypy plugin tests if mypy is missing or an unsupported version. ### Checklist This pull request is: - [ ] A documentation / typographical / small typing error fix - Good to go, no issue or tests are needed - [x] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #` in the commit message - please include tests. **Have a nice day!** Closes: #12288 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12288 Pull-request-sha: 00e00f321d54da3e5d6112f61d5770e59e33bf82 Change-Id: I492a93d3c586425e2cf53304520164dc1487a667 --- diff --git a/test/ext/mypy/test_mypy_plugin_py3k.py b/test/ext/mypy/test_mypy_plugin_py3k.py index e1aa1f9655..1d75137a04 100644 --- a/test/ext/mypy/test_mypy_plugin_py3k.py +++ b/test/ext/mypy/test_mypy_plugin_py3k.py @@ -2,6 +2,13 @@ import os import pathlib import shutil +try: + from mypy.version import __version__ as _mypy_version_str +except ImportError: + _mypy_version = None +else: + _mypy_version = tuple(int(x) for x in _mypy_version_str.split(".")) + from sqlalchemy import testing from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures @@ -24,7 +31,15 @@ def _incremental_dirs(): return files +def _mypy_missing_or_incompatible(): + return not _mypy_version or _mypy_version > (1, 10, 1) + + class MypyPluginTest(fixtures.MypyTest): + @testing.skip_if( + _mypy_missing_or_incompatible, + "Mypy must be present and compatible (<= 1.10.1)", + ) @testing.combinations( *[ (pathlib.Path(pathname).name, pathname) @@ -75,6 +90,10 @@ class MypyPluginTest(fixtures.MypyTest): % (patchfile, result[0]), ) + @testing.skip_if( + _mypy_missing_or_incompatible, + "Mypy must be present and compatible (<= 1.10.1)", + ) @testing.combinations( *( (os.path.basename(path), path, True)