Skip to content

missing-public-nested-class-documentation (PDF606)

Added in 1.0.0 Never fix By default

Part of the PDF rule category.

View source · View documentation source · Search issues

Fix is not available.

What it does

Checks for public classes nested directly in public classes that are missing docstrings.

Top-level classes are handled by the class rules, and local classes inside functions are ignored. A nested class is public when its own name, all ancestor class names, and the containing module path are public.

Why is this useful?

Nested classes do not inherit the docstring of their containing class.

Ruff compatibility

This rule replaces Ruff's D106.

Examples

A public nested class without a docstring is reported:

class Client:
    """Client."""

    class Response:
        pass
PDF606: Line 4: Public nested class 'Client.Response' is missing docstring

Multiple public nested classes are reported independently:

class Client:
    """Client."""

    class Response:
        class Payload:
            pass
PDF606: Line 4: Public nested class 'Client.Response' is missing docstring
PDF606: Line 5: Public nested class 'Client.Response.Payload' is missing docstring

Top-level classes and local classes are not nested-class targets:

class Client:
    pass

def build():
    class Local:
        pass

Nested classes under a private owner are handled by PDF607 instead:

class _Client:
    """Client."""

    class Response:
        pass

Options

None.