From 41f30796bdd07b2f2e15a0e51d1394b4970b649e Mon Sep 17 00:00:00 2001 From: Stuart Archibald Date: Tue, 21 Mar 2023 16:10:29 +0000 Subject: [PATCH] Fix typeguard import hook location. Package ``typeguard`` moved the function ``install_import_hook`` to the top level module for version 3+. This adapts the test runner to accept both the old and the new location. --- runtests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtests.py b/runtests.py index 9c37cc9970b..43dc271d55a 100755 --- a/runtests.py +++ b/runtests.py @@ -5,7 +5,13 @@ if bool(os.environ.get('NUMBA_USE_TYPEGUARD')): # The typeguard import hook must be installed prior to importing numba. # Therefore, this cannot be part of the numba package. - from typeguard.importhook import install_import_hook + try: + # version 3+ exports this at the top level + from typeguard import install_import_hook + except ImportError: + # try location for version 2.x + from typeguard.importhook import install_import_hook + install_import_hook(packages=['numba']) # ensure full tracebacks are available and no help messages appear in test mode