diff --git a/crates/ruff_linter/resources/test/fixtures/pydoclint/DOC102_numpy.py b/crates/ruff_linter/resources/test/fixtures/pydoclint/DOC102_numpy.py index ea93e16cc1..9bdac6788f 100644 --- a/crates/ruff_linter/resources/test/fixtures/pydoclint/DOC102_numpy.py +++ b/crates/ruff_linter/resources/test/fixtures/pydoclint/DOC102_numpy.py @@ -371,6 +371,61 @@ class Foo: """ return +# DOC102 - Test case from issue #20959: comma-separated parameters +def leq(x: object, y: object) -> bool: + """Compare two objects for loose equality. + + Parameters + ---------- + x1, x2 : object + Objects. + + Returns + ------- + bool + Whether the objects are identical or equal. + """ + return x is y or x == y + + +# OK - comma-separated parameters that match function signature +def compare_values(x1: int, x2: int) -> bool: + """Compare two integer values. + + Parameters + ---------- + x1, x2 : int + Values to compare. + + Returns + ------- + bool + True if values are equal. + """ + return x1 == x2 + + +# DOC102 - mixed comma-separated and regular parameters +def process_data(data, x1: str, x2: str) -> str: + """Process data with multiple string parameters. + + Parameters + ---------- + data : list + Input data to process. + x1, x2 : str + String parameters for processing. + extra_param : str + Extra parameter not in signature. + + Returns + ------- + str + Processed result. + """ + return f"{x1}{x2}{len(data)}" + + # OK def baz(x: int) -> int: """ @@ -389,3 +444,21 @@ def baz(x: int) -> int: int """ return x + + +# OK - comma-separated parameters without type annotations +def add_numbers(a, b): + """ + Adds two numbers and returns the result. + + Parameters + ---------- + a, b + The numbers to add. + + Returns + ------- + int + The sum of the two numbers. + """ + return a + b diff --git a/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs b/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs index dd88250952..97f1b7ed9b 100644 --- a/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs +++ b/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs @@ -661,19 +661,31 @@ fn parse_parameters_numpy(content: &str, content_start: TextSize) -> Vec DOC102_numpy.py:380:5 + | +378 | Parameters +379 | ---------- +380 | x1, x2 : object + | ^^ +381 | Objects. + | +help: Remove the extraneous parameter from the docstring + +DOC102 Documented parameter `x2` is not in the function's signature + --> DOC102_numpy.py:380:9 + | +378 | Parameters +379 | ---------- +380 | x1, x2 : object + | ^^ +381 | Objects. + | +help: Remove the extraneous parameter from the docstring + +DOC102 Documented parameter `extra_param` is not in the function's signature + --> DOC102_numpy.py:418:5 + | +416 | x1, x2 : str +417 | String parameters for processing. +418 | extra_param : str + | ^^^^^^^^^^^ +419 | Extra parameter not in signature. + | +help: Remove the extraneous parameter from the docstring