pylint-errors

E0118 (used-prior-global-declaration)

:x: Problematic code:

MSG = 'Outside'


def foo():
    print(MSG)

    global MSG
    MSG = 'Inside'
    print(MSG)

:heavy_check_mark: Correct code:

MSG = 'Outside'


def foo():
    global MSG
    print(MSG)

    MSG = 'Inside'
    print(MSG)

Rationale:

Emitted when a name is used prior a global declaration, which results in an error since Python 3.6. It can’t be emitted when using Python < 3.6.