making pycharn recognize additions to builtins

I am adding a global variable (to be available in all imported modules of a program) by adding it to *builtins*

How do I make pycharm stop complaining about 'unresolved reference' to such variables?

 

3 comments
Comment actions Permalink

Hi,

Please try **File > Invatidate caches / restart**. If this doesn't help, try to delete and re-install PyCharm, and delete and add the interpreter.

0
Comment actions Permalink

Invalidate caches/restart did not work.  I don't see how re-installing or deleting/adding the interpreter may work. It sounds like an IT answer to everything.

Let me reiterate the question - I add to builtins - e.g.

builtins.log = get_logger('global')

and then I use 

log.warning('beware') in all of my modules.

 

Pycharm squiggly highlight all of the *log.* instances as unresolved references. 

0
Comment actions Permalink

Well, in some cases "unresolved" errors are caused by some cache issues, and making PyCharm rebuild caches can help.

But for this case, I did some testing, and it appears to be a known issue, here's a similar ticket:

https://youtrack.jetbrains.com/issue/PY-12931

Feel free to leave a vote and comment. I should note that modifying builtins is not a common practice, there should be a better alternative.

0

Please sign in to leave a comment.