Python typing for module type

流过昼夜 提交于 2019-12-18 18:55:25

问题


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.


回答1:


You're looking for types.ModuleType.



来源:https://stackoverflow.com/questions/48389157/python-typing-for-module-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!