mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 13:24:39 +08:00
Fix trailing comma error
This commit is contained in:
committed by
Dave Halter
parent
ee2995c110
commit
e496b07b63
@@ -586,7 +586,7 @@ class _TrailingImportComma(SyntaxRule):
|
|||||||
message = "trailing comma not allowed without surrounding parentheses"
|
message = "trailing comma not allowed without surrounding parentheses"
|
||||||
|
|
||||||
def is_issue(self, node):
|
def is_issue(self, node):
|
||||||
if node.children[-1] == ',':
|
if node.children[-1] == ',' and node.parent.children[-1] != ')':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -307,3 +307,15 @@ def test_invalid_fstrings(code, message):
|
|||||||
"""
|
"""
|
||||||
error, = _get_error_list(code, version='3.6')
|
error, = _get_error_list(code, version='3.6')
|
||||||
assert message in error.message
|
assert message in error.message
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'code', [
|
||||||
|
"from foo import (\nbar,\n rab,\n)",
|
||||||
|
"from foo import (bar, rab, )",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_trailing_comma(code):
|
||||||
|
errors = _get_error_list(code)
|
||||||
|
assert not errors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user