diff --git a/ChangeLog b/ChangeLog index 817d82d220..9b26644dd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/pylint/checkers/ellipsis_checker.py b/pylint/checkers/ellipsis_checker.py index 1c7a7bebfc..48d43d3b58 100644 --- a/pylint/checkers/ellipsis_checker.py +++ b/pylint/checkers/ellipsis_checker.py @@ -49,6 +49,7 @@ def visit_const(self, node: nodes.Const) -> None: nodes.Assign, nodes.BaseContainer, nodes.Call, + nodes.Lambda, ), ) and ( diff --git a/tests/functional/u/unnecessary/unnecessary_ellipsis.py b/tests/functional/u/unnecessary/unnecessary_ellipsis.py index baba0bbc02..3e967b6cd5 100644 --- a/tests/functional/u/unnecessary/unnecessary_ellipsis.py +++ b/tests/functional/u/unnecessary/unnecessary_ellipsis.py @@ -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 = (...,) @@ -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: ...)