From 41de62c034124b50a262810e09b799b7bb650a74 Mon Sep 17 00:00:00 2001 From: jpy-git Date: Sun, 27 Mar 2022 22:49:53 +0100 Subject: [PATCH 1/3] Allow ellipsis as a default arg --- pylint/checkers/ellipsis_checker.py | 5 ++++- tests/functional/u/unnecessary/unnecessary_ellipsis.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/ellipsis_checker.py b/pylint/checkers/ellipsis_checker.py index 2d904a28d2..ac5e04095e 100644 --- a/pylint/checkers/ellipsis_checker.py +++ b/pylint/checkers/ellipsis_checker.py @@ -41,7 +41,10 @@ def visit_const(self, node: nodes.Const) -> None: """ if ( node.pytype() == "builtins.Ellipsis" - and not isinstance(node.parent, (nodes.Assign, nodes.AnnAssign, nodes.Call)) + and not isinstance( + node.parent, + (nodes.Assign, nodes.AnnAssign, nodes.Call, nodes.Arguments), + ) and ( len(node.parent.parent.child_sequence(node.parent)) > 1 or ( diff --git a/tests/functional/u/unnecessary/unnecessary_ellipsis.py b/tests/functional/u/unnecessary/unnecessary_ellipsis.py index b5a61e3493..1a6ed777c2 100644 --- a/tests/functional/u/unnecessary/unnecessary_ellipsis.py +++ b/tests/functional/u/unnecessary/unnecessary_ellipsis.py @@ -1,6 +1,6 @@ """Emit a warning when the ellipsis constant is used and can be avoided""" -# pylint: disable=missing-docstring, too-few-public-methods +# pylint: disable=missing-docstring, too-few-public-methods, invalid-name, unused-argument from typing import List, overload, Union @@ -97,3 +97,7 @@ def __getitem__(self, index: Union[int, slice]) -> Union[int, List[int]]: ... else: raise TypeError(...) + +# Ellipsis is allowed as a default argument +def func_with_ellipsis_default_arg(a = ...) -> None: + "Some docstring." From 90a27f1d8a24d89b16f63e9312fe8f691004a640 Mon Sep 17 00:00:00 2001 From: jpy-git Date: Sun, 27 Mar 2022 22:52:03 +0100 Subject: [PATCH 2/3] update changelog --- ChangeLog | 4 ++++ doc/whatsnew/2.14.rst | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1cd05d078a..e9addb44fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,10 @@ Release date: TBA Put new features here and also in 'doc/whatsnew/2.14.rst' +* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. + + Closes #5973 + * ``potential-index-error``: Emitted when the index of a list or tuple exceeds its length. This checker is currently quite conservative to avoid false positives. We welcome suggestions for improvements. diff --git a/doc/whatsnew/2.14.rst b/doc/whatsnew/2.14.rst index ad38200e7f..b8cd2cfafc 100644 --- a/doc/whatsnew/2.14.rst +++ b/doc/whatsnew/2.14.rst @@ -34,6 +34,10 @@ Extensions Other Changes ============= +* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. + + Closes #5973 + * Fix false negative for ``no-member`` when attempting to assign an instance attribute to itself without any prior assignment. From bab917381c62985c1b739fb8decbc5fc8f572943 Mon Sep 17 00:00:00 2001 From: jpy-git Date: Mon, 28 Mar 2022 10:02:52 +0100 Subject: [PATCH 3/3] Move to 2.13.3 --- ChangeLog | 8 ++++---- doc/whatsnew/2.13.rst | 4 ++++ doc/whatsnew/2.14.rst | 4 ---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 076dcf23d8..d4c184705a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,10 +10,6 @@ Release date: TBA Put new features here and also in 'doc/whatsnew/2.14.rst' -* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. - - Closes #5973 - * ``potential-index-error``: Emitted when the index of a list or tuple exceeds its length. This checker is currently quite conservative to avoid false positives. We welcome suggestions for improvements. @@ -40,6 +36,10 @@ What's New in Pylint 2.13.3? ============================ Release date: TBA +* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. + + Closes #5973 + * Fix crash involving unbalanced tuple unpacking. Closes #5998 diff --git a/doc/whatsnew/2.13.rst b/doc/whatsnew/2.13.rst index 2d425d7a4a..b2c40e87e0 100644 --- a/doc/whatsnew/2.13.rst +++ b/doc/whatsnew/2.13.rst @@ -128,6 +128,10 @@ Extensions Other Changes ============= +* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. + + Closes #5973 + * Add missing dunder methods to ``unexpected-special-method-signature`` check. * No longer emit ``no-member`` in for loops that reference ``self`` if the binary operation that diff --git a/doc/whatsnew/2.14.rst b/doc/whatsnew/2.14.rst index b8cd2cfafc..ad38200e7f 100644 --- a/doc/whatsnew/2.14.rst +++ b/doc/whatsnew/2.14.rst @@ -34,10 +34,6 @@ Extensions Other Changes ============= -* Fix false positive for ``unnecessary-ellipsis`` when using an ellipsis as a default argument. - - Closes #5973 - * Fix false negative for ``no-member`` when attempting to assign an instance attribute to itself without any prior assignment.