Back to Intellij Community

PyGlobalUndefinedInspection

python/python-psi-impl/resources/inspectionDescriptions/PyGlobalUndefinedInspection.html

2025.3-rc-2282 B
Original Source

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)