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
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
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)
% (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)