mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-16 09:27:12 +08:00
Add issue 'import * only allowed at module level'
This commit is contained in:
@@ -166,6 +166,10 @@ class ErrorFinder(Normalizer):
|
|||||||
elif name not in ALLOWED_FUTURES:
|
elif name not in ALLOWED_FUTURES:
|
||||||
message = "future feature %s is not defined" % name
|
message = "future feature %s is not defined" % name
|
||||||
self._add_syntax_error(message, node)
|
self._add_syntax_error(message, node)
|
||||||
|
elif node.type == 'import_from':
|
||||||
|
if node.is_star_import() and self._context.parent_context is not None:
|
||||||
|
message = "import * only allowed at module level"
|
||||||
|
self._add_syntax_error(message, node)
|
||||||
elif node.type == 'import_as_names':
|
elif node.type == 'import_as_names':
|
||||||
if node.children[-1] == ',':
|
if node.children[-1] == ',':
|
||||||
# from foo import a,
|
# from foo import a,
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ def test_indentation_errors(code, positions):
|
|||||||
'code', [
|
'code', [
|
||||||
'1 +',
|
'1 +',
|
||||||
'?',
|
'?',
|
||||||
|
# Python/compile.c
|
||||||
dedent('''\
|
dedent('''\
|
||||||
for a in [1]:
|
for a in [1]:
|
||||||
try:
|
try:
|
||||||
@@ -103,6 +104,7 @@ def test_indentation_errors(code, positions):
|
|||||||
|
|
||||||
# SyntaxErrors from Python/symtable.c
|
# SyntaxErrors from Python/symtable.c
|
||||||
'def f(x, x): pass',
|
'def f(x, x): pass',
|
||||||
|
'def x(): from math import *',
|
||||||
|
|
||||||
# IndentationError
|
# IndentationError
|
||||||
' foo',
|
' foo',
|
||||||
|
|||||||
Reference in New Issue
Block a user