pylint-errors

W0602 (global-variable-not-assigned)

:x: Problematic code:

var = 1


def foo():
    global v
    print(var)
    var = 10
    print(var)


foo()
print(var)

:heavy_check_mark: Correct code:

var = 1


def foo():
    global var
    print(var)
    var = 10
    print(var)


foo()
print(var)

Rationale:

Used when a variable is defined through the global statement but no assignment to this variable is done.