Skip to content

numpydoc ignore inline comment not recognized when using decorators #495

Closed
@sdiebolt

Description

@sdiebolt

When using decorators, the numpydoc ignore inline comment does not seem to be recognized by either numpydoc --validate or the validation during Sphinx build. Here's a reprex, stored as test.py:

import functools


def test_decorator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)

    return wrapper


@test_decorator
def test_function():  # numpydoc ignore=PR02
    """Test.

    Parameters
    ----------
    x : int
        Test.
    """
    print("test")

Using python -m numpydoc --validate test.test_function raises the warning test.test_function:PR02:Unknown parameters {'x'} when the decorator is used, but doesn't when the decorator is removed. Same thing when using validation during a Sphinx build. Interestingly, validation using python -m numpydoc.hooks.validate_docstrings test.py does not raise the PR02 warning, even when using the decorator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions