mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18010 Don't warn of missing parameters if none of them is mentioned in a docstring
It should help to reduce visual noise from "Incorrect docstring" inspection keeping it enabled by default at the same time.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<span style="font-family: verdana,serif;">
|
||||
This inspection detects mismatched parameters in docstring.
|
||||
This inspection detects mismatched parameters in a docstring.
|
||||
Please note that it doesn't warn you of missing parameters, if none of them is mentioned in a docstring.
|
||||
</span>
|
||||
</body>
|
||||
</html>
|
||||
@@ -28,6 +28,7 @@ import com.jetbrains.python.toolbox.Substring;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -89,6 +90,10 @@ public class PyIncorrectDocstringInspection extends PyBaseDocstringInspection {
|
||||
private static List<PyNamedParameter> getMissingParams(@NotNull StructuredDocString docString, @NotNull PyParameter[] realParams) {
|
||||
final List<PyNamedParameter> missing = new ArrayList<PyNamedParameter>();
|
||||
final List<String> docStringParameters = docString.getParameters();
|
||||
if (docStringParameters.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
for (PyParameter p : realParams) {
|
||||
final PyNamedParameter named = as(p, PyNamedParameter.class);
|
||||
if (p.isSelf() || named == null || named.isPositionalContainer() || named.isKeywordContainer()) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
""" file's docstring """
|
||||
def spam(<weak_warning descr="Missing parameter ham in docstring">ha<caret>m</weak_warning>): # <== PyCharm suggests to apply quickfix there
|
||||
"""Docstring"""
|
||||
def spam(<weak_warning descr="Missing parameter ham in docstring">ha<caret>m</weak_warning>, eggs): # <== PyCharm suggests to apply quickfix there
|
||||
"""Docstring
|
||||
@param eggs:
|
||||
"""
|
||||
pass
|
||||
@@ -1,6 +1,7 @@
|
||||
""" file's docstring """
|
||||
def spam(ham): # <== PyCharm suggests to apply quickfix there
|
||||
def spam(ham, eggs): # <== PyCharm suggests to apply quickfix there
|
||||
"""Docstring
|
||||
@param ham:
|
||||
@param eggs:
|
||||
"""
|
||||
pass
|
||||
@@ -1,3 +1,5 @@
|
||||
def f(<weak_warning descr="Missing parameter b in docstring"><caret>b</weak_warning>):
|
||||
def f(a, <weak_warning descr="Missing parameter b in docstring"><caret>b</weak_warning>):
|
||||
"""
|
||||
Args:
|
||||
a
|
||||
"""
|
||||
@@ -1,5 +1,6 @@
|
||||
def f(b):
|
||||
def f(a, b):
|
||||
"""
|
||||
Args:
|
||||
b:
|
||||
a
|
||||
"""
|
||||
@@ -65,4 +65,9 @@ def varagrs_undefined(x, *args, y, **kwargs):
|
||||
x:
|
||||
y:
|
||||
"""
|
||||
|
||||
|
||||
def no_parameters_declared(x, y):
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
@@ -49,3 +49,8 @@ def varargs_undefined(x, *args, y, **kwargs):
|
||||
@param y:
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def no_parameters_declared(x, y):
|
||||
"""
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user