PyCQA / pydocstyle

docstring style checker
http://pydocstyle.org
MIT License
1.11k stars 188 forks source link

False-positive error when parameter as a Numpy section name. #576

Open KelSolaar opened 2 years ago

KelSolaar commented 2 years ago

Hi,

I just came across a false-positive error when a parameter has a Numpy section name:

colour/plotting/tm3018/report.py:227 in public function `plot_single_sd_colour_rendition_report_full`:
        D410: Missing blank line after section ('Parameters')
colour/plotting/tm3018/report.py:227 in public function `plot_single_sd_colour_rendition_report_full`:
        D405: Section name should be properly capitalized ('Notes', not 'notes')
colour/plotting/tm3018/report.py:227 in public function `plot_single_sd_colour_rendition_report_full`:
        D411: Missing blank line before section ('Notes')
colour/plotting/tm3018/report.py:227 in public function `plot_single_sd_colour_rendition_report_full`:
        D407: Missing dashed underline after section ('Notes')

With the signature/docstring being as follows:

@override_style(**CONSTANTS_REPORT_STYLE)
def plot_single_sd_colour_rendition_report_full(
    sd: SpectralDistribution,
    source: Optional[str] = None,
    date: Optional[str] = None,
    manufacturer: Optional[str] = None,
    model: Optional[str] = None,
    notes: Optional[str] = None,
    report_size: Tuple = CONSTANT_REPORT_SIZE_FULL,
    report_row_height_ratios: Tuple = CONSTANT_REPORT_ROW_HEIGHT_RATIOS_FULL,
    report_box_padding: Optional[Dict] = None,
    **kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
    """
    Generate the full *ANSI/IES TM-30-18 Colour Rendition Report* for given
    spectral distribution.

    Parameters
    ----------
    sd
        Spectral distribution of the emission source to generate the report
        for.
    source
        Emission source name, defaults to
        `colour.SpectralDistribution_IESTM2714.header.description` or
        `colour.SpectralDistribution_IESTM2714.name` properties value.
    date
        Emission source measurement date, defaults to
        `colour.SpectralDistribution_IESTM2714.header.report_date` property
        value.
    manufacturer
        Emission source manufacturer, defaults to
        `colour.SpectralDistribution_IESTM2714.header.manufacturer` property
        value.
    model
        Emission source model, defaults to
        `colour.SpectralDistribution_IESTM2714.header.catalog_number` property
        value.
    notes
        Notes pertaining to the emission source, defaults to
        `colour.SpectralDistribution_IESTM2714.header.comments` property
        value.
    report_size
        Report size, default to A4 paper size in inches.
    report_row_height_ratios
        Report size row height ratios.
    report_box_padding
        Report box padding, tries to define the padding around the figure and
        in-between the axes.

    Other Parameters
    ----------------
    kwargs
        {:func:`colour.plotting.artist`, :func:`colour.plotting.render`},
        See the documentation of the previously listed definitions.

    Returns
    -------
    :class:`tuple`
        Current figure and axes.

    Examples
    --------
    >>> from colour import SDS_ILLUMINANTS
    >>> sd = SDS_ILLUMINANTS['FL2']
    >>> plot_single_sd_colour_rendition_report_full(sd)
    ... # doctest: +ELLIPSIS
    (<Figure size ... with ... Axes>, <...AxesSubplot...>)

    .. image:: ../_static/Plotting_\
Plot_Single_SD_Colour_Rendition_Report_Full.png
        :align: center
        :alt: plot_single_sd_colour_rendition_report_full
    """

Pre-Commit Configuration

-   repo: https://github.com/pycqa/pydocstyle
    rev: 6.1.1
    hooks:
    -   id: pydocstyle
        args:
        - --convention=numpy
        - --add-ignore=D200,D202,D205,D301,D400

Note that the parameters do not have an explicit type written because they are documented from the type hint annotations directly which is supported by Sphinx 4.x.x and Napoleon: https://colour.readthedocs.io/en/develop/generated/colour.plotting.tm3018.plot_single_sd_colour_rendition_report_full.html?highlight=plot_single_sd_colour_rendition_report_full

Cheers,

Thomas