Skip to content

missing-private-nested-class-documentation (PDF607)

Added in 1.0.0 Never fix Requires explicit

Part of the PDF rule category.

View source · View documentation source · Search issues

Fix is not available.

Rule must by default be explicitly selected, unless it is removed from require-explicit.

What it does

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

A nested class is private when its own name, an ancestor class name, or the package/module path is private.

Why is this useful?

Private nested classes can still benefit from local documentation when a project chooses to require it.

Ruff compatibility

None.

Examples

A private nested class without a docstring is reported:

class Client:
    """Client."""

    class _Response:
        pass
PDF607: Line 4: Private nested class 'Client._Response' is missing docstring

A public-looking nested class under a private top-level class is private:

class _Client:
    """Client."""

    class Response:
        pass
PDF607: Line 4: Private nested class '_Client.Response' is missing docstring

A public-looking nested class in a private module path is also private:

class Client:
    """Client."""

    class Response:
        pass
PDF607: Line 4: Private nested class 'Client.Response' is missing docstring

A documented private nested class is accepted:

class Client:
    """Client."""

    class _Response:
        """Internal response."""

Public nested classes are handled by PDF606 instead:

class Client:
    """Client."""

    class Response:
        pass

Options

None.