Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make mypy optional
  • Loading branch information
blink1073 committed Feb 10, 2022
commit d51a9cc5f7553e2ca07d02e5bb3c59b50535cbae
1 change: 1 addition & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
mongodb-version: 4.4
- name: Run tests
run: |
pip install mypy
python setup.py test

mypytest:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,5 @@ def build_extension(self, ext):
],
cmdclass={"build_ext": custom_build_ext, "doc": doc, "test": test},
extras_require=extras_require,
tests_require=["mypy"],
**extra_opts
)
10 changes: 6 additions & 4 deletions test/test_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import unittest
from typing import Any, Dict, Iterable, List

from mypy import api
try:
from mypy import api
except ImportError:
api = None

from bson.son import SON
from pymongo.collection import Collection
Expand All @@ -39,13 +42,12 @@ def get_tests() -> Iterable[str]:

class TestMypyFails(unittest.TestCase):
def ensure_mypy_fails(self, filename: str) -> None:
if api is None:
raise unittest.SkipTest("Mypy is not installed")
stdout, stderr, exit_status = api.run([filename])
self.assertTrue(exit_status, msg=stdout)

def test_mypy_failures(self) -> None:
if sys.version_info[:2] < (3, 7):
raise unittest.SkipTest("Python version >= 3.7 required.")

for filename in get_tests():
with self.subTest(filename=filename):
self.ensure_mypy_fails(filename)
Expand Down