How about checking sys.modules? You could do that in a subprocess as part of your unit tests. >>> lazy import email >>> import sys >>> sys.modules['email'] Traceback (most recent call last): File "", line 1, in KeyError: 'email' >>> email >>> sys.modules['email']
I actually found this article surprisingly interesting. I’m fairly novice at Python, but I understood the majority of what was being talked about. They do a good job at simplifying things for both new and experienced programmers to understand.
Proper link to the top of the article instead of some random comments a mile down.
https://discuss.python.org/t/pep-810-explicit-lazy-imports/104131
I actually found this article surprisingly interesting. I’m fairly novice at Python, but I understood the majority of what was being talked about. They do a good job at simplifying things for both new and experienced programmers to understand.