Skip to content

missing-private-init-documentation (PDF615)

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 __init__ methods that are missing docstrings.

An __init__ method is private when its containing class or package/module path is private.

Why is this useful?

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

Ruff compatibility

None.

Examples

An __init__ method on a private class is reported as private:

class _Client:
    """Client."""

    def __init__(self, timeout):
        self.timeout = timeout
PDF615: Line 4: Private __init__ method '_Client.__init__' is missing docstring

A public-looking __init__ method in a private module path is also private:

class Client:
    """Client."""

    def __init__(self, timeout):
        self.timeout = timeout
PDF615: Line 4: Private __init__ method 'Client.__init__' is missing docstring

A documented private __init__ method is accepted:

class _Client:
    """Client."""

    def __init__(self, timeout):
        """Initialize the internal client."""
        self.timeout = timeout

Public __init__ methods are handled by PDF614 instead:

class Client:
    """Client."""

    def __init__(self, timeout):
        self.timeout = timeout

Options