Skip to content

Commit 8b20590

Browse files
mbyrnepr2Mark ByrnePierre-Sassoulas
committed
Fix crash for unneccessary-ellipsis checker (#6038)
When an ellipsis is used inside of a list or inside a container Closes #6037 Co-authored-by: Mark Byrne <[email protected]> Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 4966c5b commit 8b20590

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Release date: TBA
2424

2525
Closes #6028
2626

27+
* Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a container.
28+
29+
Closes #6037
30+
Closes #6048
31+
32+
2733
What's New in Pylint 2.13.3?
2834
============================
2935
Release date: 2022-03-29

pylint/checkers/ellipsis_checker.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ 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+
(
47+
nodes.AnnAssign,
48+
nodes.Arguments,
49+
nodes.Assign,
50+
nodes.BaseContainer,
51+
nodes.Call,
52+
),
4753
)
4854
and (
4955
len(node.parent.parent.child_sequence(node.parent)) > 1

tests/functional/u/unnecessary/unnecessary_ellipsis.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,14 @@ 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 container:
107+
my_list = [...]
108+
my_tuple = (...,)
109+
my_set = {...}
110+
111+
# Ellipsis inside a container which is a value in a dictionary
112+
mydict1 = {'x': [...]}
113+
mydict2 = {'x': {...}}
114+
mydict3 = {'x': (...,)}

0 commit comments

Comments
 (0)