Skip to content

Commit

Permalink
Fix false positive for the unnecessary-ellipsis checker (#6039)
Browse files Browse the repository at this point in the history
When an ellipsis is used in a lambda expression.

  Closes #6036

Co-authored-by: Mark Byrne <mark.byrne@rabobank.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
3 people committed Mar 31, 2022
1 parent 8b20590 commit 5ea03af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Expand Up @@ -24,8 +24,9 @@ Release date: TBA

Closes #6028

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

Closes #6036
Closes #6037
Closes #6048

Expand Down
1 change: 1 addition & 0 deletions pylint/checkers/ellipsis_checker.py
Expand Up @@ -49,6 +49,7 @@ def visit_const(self, node: nodes.Const) -> None:
nodes.Assign,
nodes.BaseContainer,
nodes.Call,
nodes.Lambda,
),
)
and (
Expand Down
4 changes: 3 additions & 1 deletion tests/functional/u/unnecessary/unnecessary_ellipsis.py
Expand Up @@ -102,7 +102,6 @@ def __getitem__(self, index: Union[int, slice]) -> Union[int, List[int]]:
def func_with_ellipsis_default_arg(a = ...) -> None:
"Some docstring."


# Ignore if the ellipsis is inside a container:
my_list = [...]
my_tuple = (...,)
Expand All @@ -112,3 +111,6 @@ def func_with_ellipsis_default_arg(a = ...) -> None:
mydict1 = {'x': [...]}
mydict2 = {'x': {...}}
mydict3 = {'x': (...,)}

# Ignore if the ellipsis is used with a lambda expression
print("x", lambda: ...)

0 comments on commit 5ea03af

Please sign in to comment.