With the new syntax, the ImportError will raise on it’s own if there is an issue resolving the import on first use. It is not necessary to muck around globals to try and find the module and materialize it, simply referencing the module will raise the import error.
To mirror the functionality pasted as an example:
lazy import numpy
def some_func():
try:
numpy
except ImportError as exc:
raise RuntimeError("numpy is required for using some_func!") from exc
Edit: I’d also like to make it clear that it would make just as much sense to replace the code within the try block with whatever business logic you were intending to execute using numpy from within some_func. In addition, if you’re okay with the user seeing the ImportError in lieu of the RuntimeError, you could remove the try/except entirely.