Skip to content

Commit 789a381

Browse files
mbyrnepr2Mark ByrnePierre-Sassoulas
authored
Fix false positive for the unnecessary-ellipsis checker (#6039)
When an ellipsis is used in a lambda expression. Closes #6036 Co-authored-by: Mark Byrne <[email protected]> Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent d12c770 commit 789a381

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

ChangeLog

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ Release date: TBA
4545

4646
Closes #6028
4747

48-
* Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a container.
48+
* Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a container or a lambda expression.
4949

50+
Closes #6036
5051
Closes #6037
5152
Closes #6048
5253

pylint/checkers/ellipsis_checker.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def visit_const(self, node: nodes.Const) -> None:
4949
nodes.Assign,
5050
nodes.BaseContainer,
5151
nodes.Call,
52+
nodes.Lambda,
5253
),
5354
)
5455
and (

tests/functional/u/unnecessary/unnecessary_ellipsis.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def __getitem__(self, index: Union[int, slice]) -> Union[int, List[int]]:
102102
def func_with_ellipsis_default_arg(a = ...) -> None:
103103
"Some docstring."
104104

105-
106105
# Ignore if the ellipsis is inside a container:
107106
my_list = [...]
108107
my_tuple = (...,)
@@ -112,3 +111,6 @@ def func_with_ellipsis_default_arg(a = ...) -> None:
112111
mydict1 = {'x': [...]}
113112
mydict2 = {'x': {...}}
114113
mydict3 = {'x': (...,)}
114+
115+
# Ignore if the ellipsis is used with a lambda expression
116+
print("x", lambda: ...)

0 commit comments

Comments
 (0)