In pycharm, when I import a local module (from the same directory), I would like to get rid of the Unresolved references warning :
without marking the local directory as a sources root, and
without unchecking the settings->Editor->Inspections->Python-> Unresolved references option
I think it is a fair request as, if I am not wrong, python allows to import a module from the same directory. My understanding is that the local directory (the "." directory) in implicitly in the PYTHON PATH.
The code actually works in command line (without putting the directory in any PYTHON PATH) but also in pycharm, which is ironic. It works but pycharm:
shows Unresolved references warning and
a CRL B on the imported function won't work and show up "can not find declaration to go to"
Code example :
Structure:
import_test1 (directory not mark as sources root)
__init__.py (same behaviour if not present)
main.py
tools1.py
main.py:
from tools1 import add # =====> Unresolved references of tools1
print(add(2,3)) #=====> CRTL B does not work on add()
tools1.py:
def add(a, b):
return a + b
Is there a way to get rid of the annoying behaviour ?
If not, what is the rationale behind it?
PS: This question is quite specific and I don't think it is a duplicate though it looks like other questions.