Skip to content

D403 first-line-capitalized lint not alerting when the first line is after a newline #14890

@yoav-alexander

Description

@yoav-alexander

My Ruff version is 0.8.2.

When using first-line-capitalized (D403) in conjunction with multi-line-summary-second-line (D213)
ruff fails to alert about the first line missing capitalization:

def fibonacci(n: int) -> int:
    """
    calculate the nth Fibonacci number.

    The Fibonacci sequence is defined as:
        F(0) = 0, F(1) = 1
        F(n) = F(n-1) + F(n-2) for n > 1

    Args:
        n (int): The position in the Fibonacci sequence (must be non-negative).
    ...
    """

The ruff output is :

All checks passed!

I think the correct action would be to alert the user about the missing capitalization since the lint is basically useless when using D213.
Moreover, and most importantly, this is a deviation from how pydocstyle works, from which both of those alerts are
derived.

pydocstyle:

main.py:3 in public function `fibonacci`:
        D403: First word of the first line should be properly capitalized ('Calculate', not 'calculate')

If this change is accepted I think there are merits to renaming first-line-capitalized (D403)
to something like docstring-start-capitalized to avoid confusion with multi-line-summary-second-line (D213)
and multi-line-summary-first-line (D212) which are all derived from pydocstyle.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocstringRelated to docstring linting or formattinghelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions