Python

Python

Made by DeepSource

Name used prior global declaration PYL-E0118

Bug risk
Critical
Autofix

A global variable is being accessed in a local scope before it has been defined with a global statement. Doing so will raise a SyntaxError.

Bad practice

var = "Some Value"


def foo():
    var = "New value"
    global var
    ...

Preferred

var = "Some Value"


def foo():
    global var
    var = "New value"
    ...