Skip to content

Commit

Permalink
Fix and rename requires_numpy_typing decorator (#1710)
Browse files Browse the repository at this point in the history
PR #1682 introduced what should have been a check for numpy.typing, that ended up as a check for numpy.testing instead. This PR fixes that.

Also, PR #1682 should have failed on Python 3.6 because of the above, since on Python 3.6 the latest version of NumPy available doesn't have type hints. It didn't fail because we weren't populating the package data with the new numpy_examples directory, so the numpy-based tests weren't run. That's fixed in #1709.
  • Loading branch information
mdickinson committed Aug 12, 2022
1 parent 41a97b8 commit 60eec74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions traits-stubs/traits_stubs_tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from traits.testing.optional_dependencies import (
pkg_resources,
requires_mypy,
requires_numpy_testing,
requires_numpy_typing,
requires_pkg_resources,
)
from traits_stubs_tests.util import MypyAssertions
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_all(self, filename_suffix=""):
with self.subTest(file_path=file_path):
self.assertRaisesMypyError(file_path)

@requires_numpy_testing
@requires_numpy_typing
def test_numpy_examples(self):
""" Run mypy for files contained in traits_stubs_tests/numpy_examples
directory.
Expand Down
6 changes: 3 additions & 3 deletions traits/testing/optional_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def optional_import(name):
numpy = optional_import("numpy")
requires_numpy = unittest.skipIf(numpy is None, "NumPy not available")

numpy_testing = optional_import("numpy.testing")
requires_numpy_testing = unittest.skipIf(
numpy_testing is None, "numpy.testing not available")
numpy_typing = optional_import("numpy.typing")
requires_numpy_typing = unittest.skipIf(
numpy_typing is None, "numpy.typing not available")

pkg_resources = optional_import("pkg_resources")
requires_pkg_resources = unittest.skipIf(
Expand Down

0 comments on commit 60eec74

Please sign in to comment.