summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Young <80432516+jpy-git@users.noreply.github.com>2022-03-28 10:27:32 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2022-03-29 10:41:55 +0200
commitc73353064f934ae49472eb6138e1f8071b6b733e (patch)
tree904f9548ea247849f45aacc7deb0d41478b3d664
parent19e6531068cf95d602054ff8638adcb79971d552 (diff)
downloadpylint-git-c73353064f934ae49472eb6138e1f8071b6b733e.tar.gz
`unnecessary-ellipsis` false positive: allow ellipsis as default argument (#6007)
-rw-r--r--ChangeLog4
-rw-r--r--doc/whatsnew/2.13.rst4
-rw-r--r--pylint/checkers/ellipsis_checker.py5
-rw-r--r--tests/functional/u/unnecessary/unnecessary_ellipsis.py6
4 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 22fe55cae..ef8c38843 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,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 2d425d7a4..b2c40e87e 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/pylint/checkers/ellipsis_checker.py b/pylint/checkers/ellipsis_checker.py
index 2d904a28d..ac5e04095 100644
--- a/pylint/checkers/ellipsis_checker.py
+++ b/pylint/checkers/ellipsis_checker.py
@@ -41,7 +41,10 @@ class EllipsisChecker(BaseChecker):
"""
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 b5a61e349..1a6ed777c 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 @@ class MyIntegerList(List[int]):
...
else:
raise TypeError(...)
+
+# Ellipsis is allowed as a default argument
+def func_with_ellipsis_default_arg(a = ...) -> None:
+ "Some docstring."