]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Skip mypy plugin tests if incompatible or missing
authorNils Philippsen <nils@tiptoe.de>
Thu, 30 Jan 2025 13:10:55 +0000 (08:10 -0500)
committersqla-tester <sqla-tester@sqlalchemy.org>
Thu, 30 Jan 2025 13:10:55 +0000 (08:10 -0500)
Fixes: #12287
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->

This skips Mypy plugin tests if mypy is missing or an unsupported version.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

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: #<issue number>` 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: #<issue number>` 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

test/ext/mypy/test_mypy_plugin_py3k.py

index e1aa1f9655120706e8d5b4871d2fb530dca7b68f..1d75137a0429a96cf5ae43ff10d3722ec5a62f4a 100644 (file)
@@ -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)