Inspectopedia Help

Global variable is not defined at the module level

Reports problems when a variable defined through the global statement is not defined in the module scope.

Example:

def foo(): global bar print(bar) foo()

As a fix, you can move the global variable declaration:

global bar def foo(): print(bar)

Inspection Details

Available in:

DataSpell 2023.3, PyCharm 2023.3

Plugin:

Python Community Edition, 233.SNAPSHOT

Last modified: 13 July 2023