Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive for the unnecessary-ellipsis checker #6039

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Release date: TBA

Closes #6028

* Fix false positive for the ``unnecessary-ellipsis`` checker when an ellipsis is used in a lambda expression.

Closes #6036


What's New in Pylint 2.13.3?
============================
Expand Down
8 changes: 7 additions & 1 deletion pylint/checkers/ellipsis_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ 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.Lambda,
),
)
and (
len(node.parent.parent.child_sequence(node.parent)) > 1
Expand Down
3 changes: 3 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,6 @@ 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 used with a lambda expression
print("x", lambda: ...)