Hint PyCharm that an object is defined
Hello,
I have the following bit of code in Python:
Since getdsip is not visible by the interpreter before runtime it gets tagged as an unknown module by PyCharm. Is there a way to "hint" the IDE that this module does indeed exist and therefore no warning should be issued?
This question could be extended: if the import statement was from getdsip import * then any class name would be unknown to the IDE (and it would be good to be able to "hint" it as per above)
Thank you!
I have the following bit of code in Python:
sys.path.append(os.path.join(sys.path[0], "..", "..", "getdsip")) try: from getdsip import GetDSIP except: print("ERROR: cannot load GetDSIP") os.sys.exit()
Since getdsip is not visible by the interpreter before runtime it gets tagged as an unknown module by PyCharm. Is there a way to "hint" the IDE that this module does indeed exist and therefore no warning should be issued?
This question could be extended: if the import statement was from getdsip import * then any class name would be unknown to the IDE (and it would be good to be able to "hint" it as per above)
Thank you!
Please sign in to leave a comment.
Note that you can tweak your PYTHONPATH instead of modifying sys.path in your code.
As for PYTHONPATH: the location of the module will be different between systems - the only thing which is required is that it is ".." relative to the script directory. I dod not found a better way to handle this in the code.