Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mypy an optional dependency #1289

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions traits-stubs/traits_stubs_tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import pkg_resources

from traits.testing.optional_dependencies import requires_mypy
from traits_stubs_tests.util import MypyAssertions


@requires_mypy
class TestAnnotations(TestCase, MypyAssertions):
def test_all(self, filename_suffix=''):
""" Run mypy for all files contained in traits_stubs_tests/examples
Expand Down
5 changes: 3 additions & 2 deletions traits-stubs/traits_stubs_tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import re
import tempfile

from mypy import api as mypy_api


def parse_py_file(filepath):
""" This function parses a python file that have been annotated with error
Expand Down Expand Up @@ -98,6 +96,9 @@ def run_mypy(filepath):
The exit status

"""
# Local import to make it easier to skip tests if mypy is not in
# the environment.
from mypy import api as mypy_api

# Need to use tempdir since mypy complains that:
# "site-packages is in PYTHONPATH. Please change directory so it is not."
Expand Down
3 changes: 3 additions & 0 deletions traits/testing/optional_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def optional_import(name):
cython = optional_import("cython")
requires_cython = unittest.skipIf(cython is None, "Cython not available")

mypy = optional_import("mypy")
requires_mypy = unittest.skipIf(mypy is None, "Mypy not available")

numpy = optional_import("numpy")
requires_numpy = unittest.skipIf(numpy is None, "NumPy not available")

Expand Down