Skip to content

Commit 3468344

Browse files
author
Mark Byrne
committed
Fix crash for unneccessary-ellipsis checker when an ellipsis is used inside of a list.
Closes #6037
1 parent 2885eef commit 3468344

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Release date: TBA
2828

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

31+
* Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a list.
32+
33+
Closes #6037
34+
3135
..
3236
Insert your changelog randomly, it will reduce merge conflicts
3337
(Ie. not necessarily at the end)

pylint/checkers/ellipsis_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def visit_const(self, node: nodes.Const) -> None:
4343
node.pytype() == "builtins.Ellipsis"
4444
and not isinstance(
4545
node.parent,
46-
(nodes.Assign, nodes.AnnAssign, nodes.Call, nodes.Arguments),
46+
(nodes.Assign, nodes.AnnAssign, nodes.Call, nodes.Arguments, nodes.List),
4747
)
4848
and (
4949
len(node.parent.parent.child_sequence(node.parent)) > 1

tests/functional/u/unnecessary/unnecessary_ellipsis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,8 @@ def __getitem__(self, index: Union[int, slice]) -> Union[int, List[int]]:
101101
# Ellipsis is allowed as a default argument
102102
def func_with_ellipsis_default_arg(a = ...) -> None:
103103
"Some docstring."
104+
105+
106+
# Ignore if the ellipsis is inside a list
107+
x = [...]
108+
y = {'a': [...]}

0 commit comments

Comments
 (0)