Due to dynamic binding. Python is a dynamic language in such a way that you can do almost everything with your variables. You can even access globals-dict and introduce new variables consisting of runtime values.
Thus, the IDE cannot be sure which variables exist when. See this example:
#silly.py import sys if len(sys.argv) > 1: thisNowExists = True #1 try: if thisNowExists: print("this existed before") except NameError: print("this _now_ exists") thisNowExists = True
No person or IDE can know if thisNowExists defined in position #1 , so if you want to rename the stupidly named thisNowExists below this point, it is undefined if we need to rename the appearance before #1 too.
You will need to conduct an extended control flow analysis to understand well that thisNowExists is defined below with a try / catch statement, but due to the dynamic loading of the script ( thisNowExists = 1; import silly ) and sorting it might even exist before import sys with no arguments.
Naming your variables in different ways, and finding / replacing is your best bet;)
source share