section-name-trailing-content (PDF403)¶
PDF402 section-name-term-normalization
Next rule →PDF404 section-name-trailing-colon
Part of the PDF rule category.
View source · View documentation source · Search issues
Fix is sometimes available.
Rule is disabled if docstring-convention is none, pep257, numpy, or rest.
What it does¶
PDF403 reports recognized Google section names that have section content on the same logical line when that line is parsed as ordinary paragraph text. The target layout keeps the section name on its own line and moves the trailing content to the next line at the configured Google section body indentation.
The rule skips summary lines, protected structures such as code fences, and text inside already parsed convention sections. The fix is available for safely mapped simple docstrings. Concatenated docstrings and source mappings that cannot be safely rewritten are reported without a fix.
Why is this useful?¶
Keeping section names on their own line makes section boundaries unambiguous for readers and convention-aware parsers.
Ruff compatibility¶
This rule covers a Google-specific section-header cleanup. Ruff's current D406 default is NumPy-only, but pydocformatter enables PDF403 by default under the Google convention because the rule only affects recognized Google section headers.
Examples¶
PDF403 moves same-line Google section content below the section name:
docstring-convention = "google"
def value(arg):
"""Return the value.
Args: arg: The value.
"""
def value(arg):
"""Return the value.
Args:
arg: The value.
"""
Multiple same-line section headers in one docstring are fixed together:
docstring-convention = "google"
def value(arg):
"""Return the value.
Args: arg: The value.
Returns: int: The value.
Raises: ValueError: If the value is invalid.
"""
def value(arg):
"""Return the value.
Args:
arg: The value.
Returns:
int: The value.
Raises:
ValueError: If the value is invalid.
"""
PDF403 does not capitalize section names while moving content. That is handled by PDF400:
docstring-convention = "google"
def value(arg):
"""Return the value.
args: arg: The value.
"""
def value(arg):
"""Return the value.
args:
arg: The value.
"""
Summary lines that begin with a section-like prefix are not section headers:
docstring-convention = "google"
def is_valid(arg):
"""Returns: True when the value is valid."""
The rule also skips protected blocks such as code fences:
docstring-convention = "google"
def example():
"""Show command output.
```text
Args: printed by the command.
```
"""
Options¶
indent-style: Indentation style used for content moved below the section name.indent-width: Indentation width used for content moved below the section name.
PDF402 section-name-term-normalization
Next rule →PDF404 section-name-trailing-colon