Skip to content

Commit

Permalink
Fix crash for unneccessary-ellipsis checker when an ellipsis is u…
Browse files Browse the repository at this point in the history
…sed inside of a list.

Closes #6037
  • Loading branch information
Mark Byrne committed Mar 29, 2022
1 parent 2885eef commit 3468344
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Release date: TBA

* Fix bug where specifically enabling just ``await-outside-async`` was not possible.

* Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a list.

Closes #6037

..
Insert your changelog randomly, it will reduce merge conflicts
(Ie. not necessarily at the end)
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/ellipsis_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def visit_const(self, node: nodes.Const) -> None:
node.pytype() == "builtins.Ellipsis"
and not isinstance(
node.parent,
(nodes.Assign, nodes.AnnAssign, nodes.Call, nodes.Arguments),
(nodes.Assign, nodes.AnnAssign, nodes.Call, nodes.Arguments, nodes.List),
)
and (
len(node.parent.parent.child_sequence(node.parent)) > 1
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/u/unnecessary/unnecessary_ellipsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@ def __getitem__(self, index: Union[int, slice]) -> Union[int, List[int]]:
# Ellipsis is allowed as a default argument
def func_with_ellipsis_default_arg(a = ...) -> None:
"Some docstring."


# Ignore if the ellipsis is inside a list
x = [...]
y = {'a': [...]}

0 comments on commit 3468344

Please sign in to comment.