numpy / numpy/numpydoc

Feature Request: ignore @overload decorated objects

Open
#559 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
355
Forks
181
Avg merge
1d 9h
Merged PRs (30d)
3

Description

Overloaded functions should not have docstrings as the docstrings should be in the implemented function.

Maybe I missed something, but is there a way to ignore all @overload decorated functions?

This file should not raise any errors

"""File docstring."""

from typing import overload

@overload
def hello(a: str) -> str: ...

@overload
def hello(a: int) -> int: ...

def hello(a: str | int) -> str | int:
    """Return a.

    Parameters
    ----------
    a : int or str
        Parameter a.
    
    Returns
    -------
    int or str
        Returns a.
    """

    return a

numpydoc lint file.py --ignore ES01 SA01 EX01 GL01 does raise this

+-----------------------------------+----------------+---------+--------------------------------------+
| file                              | item           | check   | description                          |
+===================================+================+=========+======================================+
| .\src\test_numpydoc\__init__.py:6 | __init__.hello | GL08    | The object does not have a docstring |
+-----------------------------------+----------------+---------+--------------------------------------+
| .\src\test_numpydoc\__init__.py:9 | __init__.hello | GL08    | The object does not have a docstring |
+-----------------------------------+----------------+---------+--------------------------------------+

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running numpydoc lint file.py --ignore ES01 SA01 EX01 GL01 against the overload example in the issue and trace the GL08 reports for the decorated functions. Update the lint behavior so overloaded declarations do not raise missing-docstring errors, while the implemented function remains checked, and add or run coverage for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.