How to fix inspections etc. for import dynamically __init__.py files adding stuff to globals()?
已回答
In a project I'm working on we have this code in one of our __init__.py files:
As you can imagine, any imports from that module show up as unresolved references. This is INCREDIBLY annoying. Is there any way to make PyCharm know that any imports from that package can come from any module inside it?
for f in os.listdir(os.path.dirname(__file__)):
if f.endswith('.py'):
module = importlib.import_module('indico.modules.rb.models.{}'.format(f[:-3]))
globals().update(module.__dict__)
As you can imagine, any imports from that module show up as unresolved references. This is INCREDIBLY annoying. Is there any way to make PyCharm know that any imports from that package can come from any module inside it?
请先登录再写评论。
Anyone figure this out?
The only thing which comes to my mind is to write custom pyi stubs for your code.