Skip to content

Fix false positive for the unnecessary-ellipsis checker #6039

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

Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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: ...)