Skip to content

Commit

Permalink
python.gram: stricter rule for trailing comma in import (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuDartiailh authored Aug 19, 2021
1 parent a806a6a commit d130038
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ invalid_group[NoReturn]:
self.raise_syntax_error_known_location("cannot use double starred expression here", a)
}
invalid_import_from_targets[NoReturn]:
| import_from_as_names ',' {
| import_from_as_names ',' NEWLINE {
self.raise_syntax_error("trailing comma not allowed without surrounding parentheses")
}

Expand Down
1 change: 1 addition & 0 deletions tests/python_parser/test_syntax_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def test_invalid_group(python_parse_file, python_parse_str, tmp_path, source, me
"source, message",
[
("from a import b,", "trailing comma not allowed without surrounding parentheses"),
("from a import b, and 3", "invalid syntax"),
("from a import raise", "invalid syntax"),
],
)
Expand Down

0 comments on commit d130038

Please sign in to comment.