From 6eb37ebc21509894c06fa52d92a1f2f916bc5c3c Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sun, 1 Oct 2023 10:42:00 -0300 Subject: [PATCH] Properly consider that a method containing ... is an empty method and don't report unused arguments in it. --- .../analysis/visitors/MessagesManager.java | 7 +++++++ .../analysis/OccurrencesAnalyzerPy310Test.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/visitors/MessagesManager.java b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/visitors/MessagesManager.java index a2ff95b035..4de3f05bee 100644 --- a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/visitors/MessagesManager.java +++ b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/visitors/MessagesManager.java @@ -348,6 +348,13 @@ public void addUnusedMessage(SimpleNode node, Found f) { if (expr.value instanceof Str) { continue; } + if (expr.value instanceof Name) { + Name name = (Name) expr.value; + if ("...".equals(name.id)) { + continue; + } + + } } addMessage = true; break; diff --git a/plugins/org.python.pydev/tests_analysis/com/python/pydev/analysis/OccurrencesAnalyzerPy310Test.java b/plugins/org.python.pydev/tests_analysis/com/python/pydev/analysis/OccurrencesAnalyzerPy310Test.java index f91e43ef59..53d9bd5010 100644 --- a/plugins/org.python.pydev/tests_analysis/com/python/pydev/analysis/OccurrencesAnalyzerPy310Test.java +++ b/plugins/org.python.pydev/tests_analysis/com/python/pydev/analysis/OccurrencesAnalyzerPy310Test.java @@ -707,4 +707,21 @@ public void testTypingWithLiterals() { + ""); checkNoError(); } + + public void testOverload() { + doc = new Document("from typing import overload\n" + + "\n" + + "\n" + + "class C:\n" + + " @overload\n" + + " def foo(self, a: int) -> None: ...\n" + + "\n" + + " @overload\n" + + " def foo(self, a: str) -> None: ...\n" + + "\n" + + " def foo(self, a: int | str) -> None:\n" + + " print(a) # dummy impl" + + ""); + checkNoError(); + } }