summaryrefslogtreecommitdiff
path: root/pylint/checkers/base
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2022-09-19 09:54:55 -0300
committerGitHub <noreply@github.com>2022-09-19 14:54:55 +0200
commitf88ca428a493d4fb357fa9896fea24dea6a225e4 (patch)
tree72902e72196fd2e9517bd9bc6677b867909a4090 /pylint/checkers/base
parent7f0e27e22887ead5d323798e70b8cc802790e1a4 (diff)
downloadpylint-git-f88ca428a493d4fb357fa9896fea24dea6a225e4.tar.gz
Update assert-on-tuple for any populated tuple (#7468)
Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/checkers/base')
-rw-r--r--pylint/checkers/base/basic_checker.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/pylint/checkers/base/basic_checker.py b/pylint/checkers/base/basic_checker.py
index 4594bbaa8..6ea7197b3 100644
--- a/pylint/checkers/base/basic_checker.py
+++ b/pylint/checkers/base/basic_checker.py
@@ -188,7 +188,7 @@ class BasicChecker(_BasicChecker):
"re-raised.",
),
"W0199": (
- "Assert called on a 2-item-tuple. Did you mean 'assert x,y'?",
+ "Assert called on a populated tuple. Did you mean 'assert x,y'?",
"assert-on-tuple",
"A call of assert on a tuple will always evaluate to true if "
"the tuple is not empty, and will always evaluate to false if "
@@ -680,12 +680,8 @@ class BasicChecker(_BasicChecker):
@utils.only_required_for_messages("assert-on-tuple", "assert-on-string-literal")
def visit_assert(self, node: nodes.Assert) -> None:
"""Check whether assert is used on a tuple or string literal."""
- if (
- node.fail is None
- and isinstance(node.test, nodes.Tuple)
- and len(node.test.elts) == 2
- ):
- self.add_message("assert-on-tuple", node=node)
+ if isinstance(node.test, nodes.Tuple) and len(node.test.elts) > 0:
+ self.add_message("assert-on-tuple", node=node, confidence=HIGH)
if isinstance(node.test, nodes.Const) and isinstance(node.test.value, str):
if node.test.value: