This is perfectly valid code:
globals().update({"variable": "val"})
variable
# do-something-with-variable
However, PyCharm is not able to recognise the variable:
I don't want to disable the marking of unresolved references; it is a very useful feature. I want PyCharm to recognise my variable. How can I do this? (even if it is a dirty trick for development that I will later erase in production)
Explanation
I would not care about globals().update if it were not for that Python's multiprocessing module from version 3.4 incorporates dynamic creation of variables through a context class instead of defining them in the __init__.py file (see this link) For this reason, PyCharm does not recognise the module's attributes at all, so I have to be looking up docs constantly instead of making use of PyCharm's introspective features for this package, let alone not getting the unresolved reference error that makes me doubt constantly of whether I am getting the code right or not. Basically like writing code in Windows' notepad ;-)
