Python typing for module type

Question:

I am dynamically loading a Python module using importlib.import_module as follows

    def load_module(mod_name: str) -> ???:
        return importlib.import_module(mod_name)

Can somebody tell me what is the correct type annotation for a module type. The typing module does not contain one and I could not find an answer elsewhere.

Asked By: andrekupka

||

Answers:

You’re looking for types.ModuleType.

Answered By: Aran-Fey