coala

Detect undefined variable referenced by `global` keyword in Python code

Pyflakes is a static analysis tool that detects errors in Python code.

Currently, Pyflakes does not detect some invalid uses of the global keyword:

For example, given this code:

def main():
    global x
    print(x)

main()

Python will give an error:

NameError: name 'x' is not defined

Currently, Pyflakes does not complain. We want to add a feature to make it report a message like:

foo.py:2: undefined name 'x'

Task tags

  • python
  • pyflakes
  • linter
  • analysis
  • ast

Students who completed this task

Joshua Chung

Task type

  • code Code
close

2017