used-prior-global-declaration / E0118#

Message emitted:

Name %r is used prior to global declaration

Description:

Emitted when a name is used prior a global declaration, which results in an error since Python 3.6.

Correct code:

TOMATO = "black cherry"


def update_tomato():
    global TOMATO
    TOMATO = "moneymaker"

Problematic code:

TOMATO = "black cherry"


def update_tomato():
    print(TOMATO)  # [used-prior-global-declaration]
    global TOMATO
    TOMATO = "cherry tomato"

Created by the basic checker.