Using global for 'prior_stats' but no assignment is done
75
76def recordMetrics():
77 global lastUsage
78 global prior_stats 79 myStats = stats.copy()
80 myPriorStats = {}
81 stats.clear()
Using global for 'lastUsage' but no assignment is done
74
75
76def recordMetrics():
77 global lastUsage 78 global prior_stats
79 myStats = stats.copy()
80 myPriorStats = {}
Using global for 'settings' but no assignment is done
233 ]
234
235 def postOptions(self):
236 global settings237
238 program = self.parent.subCommand
239
Description
The variable is defined through the global
statement but no assignment to this variable is done. It is recommended to remove it if not necessary.
Bad practice
def my_func():
global a
return a
Recommended
If it is a newly defined global, make sure to assign a value to it.
def my_func():
global a
a = 1 # Assign to the newly defined global value.
return a
Or if the global should be already defined, you can remove the global
statement.
a = 1
def my_func():
return a # The global statement can be removed
Note: DeepSource will remove the global
statement during autofix.