From 8bcffa965e61efcddf493c5eebef657e7d757629 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Fri, 9 Apr 2021 14:18:04 -0700 Subject: [PATCH] Skip mypy test on platforms using importlib_resources --- sros2/test/test_mypy.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sros2/test/test_mypy.py b/sros2/test/test_mypy.py index 331a3b88..5bd7adf8 100644 --- a/sros2/test/test_mypy.py +++ b/sros2/test/test_mypy.py @@ -19,4 +19,13 @@ @pytest.mark.mypy @pytest.mark.linter def test_mypy(): + try: + import importlib.resources as _ + except ModuleNotFoundError: + # The importlib_resources package is a backport of the importlib.resources module + # from Python 3.9. The 'policy' module of this project first tries to import from + # importlib.resources, then falls back to the backport package. + # There is a bug in mypy that manifests when this try/except import pattern is + # used: https://github.com/python/mypy/issues/1153 + pytest.skip('This platform does not support mypy checking of importlib properly') assert main(argv=[]) == 0, 'Found errors'