Is there some way to get PyCharm to inspect modules which are imported via try/except?
sys = None
sys.exit() # <-- does not inspect
sys.exit() # <-- inspects
I was reading through another thread
which makes mention of using docstrings or some asserts to get the autocompletion to work within the scope of that function/class. I thought perhaps these ideas could be applied here. If so, I'm not able to figure out how.
I was thinking of something along these lines...
assert isinstance(sys, sys)
Clearly, this doesn't actually work but I hope you get the idea. Doing this...
proves the variable is a module, but doesn't seem to have an affect on Pycharm's inspection (not that I expected it would).
So is there something like this that I can do to get inspection to work when the module has been wrapped in a try/except?
(I'm even willing to hear suggestions in code changes, provided I'm still able to wrap the import in some sort of try/except)