Unresolved reference inspected for package level names appearing in __main__ module

Answered

I continuously get inspection errors when trying to import names directly from the package. These names appear in the package's __main__ module. Needless to say, any autocomplete features are unusable.

An example for this would be the mongoengine package. After installing the package into my active virtual environment (using poetry), I try importing its contents,

Looking at the mongoengine's packge __init__, we can see that it is importing names from its modules, allowing them to be imported at the pacakge level:

Unfortunately, I can't seem to make PyCharm aware of those names, neither did I find any related help online.

 

Your help would be seriously appreciated.

Many thanks,

Simon

2 comments

Hi Simon,

It looks like __init__.py file is not associated with python file type. Please check that it is not assigned to Text file type under Preferences | Editor | File Types. Also make sure it is not among Ignore files and folders of Python file type.

1

Yay! Apparently __init__.py was a registered pattern for Text files!

Thanks for the help!


1

Please sign in to leave a comment.