Better checking of annotations/params and nonlocals/globals.

This commit is contained in:
Dave Halter
2017-07-30 12:23:17 +02:00
parent b7726d05cf
commit 2420f57a5c
3 changed files with 71 additions and 6 deletions

View File

@@ -176,6 +176,42 @@ def test_indentation_errors(code, positions):
def glob():
x
nonlocal x'''),
# Annotation issues
dedent('''
def glob():
x[0]: foo
global x'''),
dedent('''
def glob():
x.a: foo
global x'''),
dedent('''
def glob():
x: foo
global x'''),
dedent('''
def glob():
x: foo = 5
global x'''),
dedent('''
def glob():
x: foo = 5
x
global x'''),
dedent('''
def glob():
global x
x: foo = 3
'''),
# global/nonlocal + param
dedent('''
def glob(x):
global x
'''),
dedent('''
def glob(x):
nonlocal x
'''),
# IndentationError
' foo',