Skip to content

Commit

Permalink
Fix typeguard import hook location.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stuartarchibald committed Mar 21, 2023
1 parent 07f824e commit 41f3079
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41f3079

Please sign in to comment.