Open
Description
The error message is poor for code like this where we don't initialize or declare a global variable at the module top level:
from typing import List
def foo() -> None:
global bar
bar = [] # type: List[str] # Name 'bar' already defined (possibly by an import)
bar # Name 'bar' is not defined
It would be better to be explicit and say something like "Global variable must be declared or initialized at module top level".
Follow-up to #6975.