Skip to content

griffe_warnings_deprecated ¤

griffe-warnings-deprecated package.

Griffe extension for @warnings.deprecated (PEP 702).

Modules:

  • extension

    Deprecated. Import from griffe_warnings_deprecated directly.

Classes:

WarningsDeprecatedExtension ¤

WarningsDeprecatedExtension(
    kind: str = "danger",
    title: str | None = "Deprecated",
    label: str | None = "deprecated",
)

Bases: Extension

Griffe extension for @warnings.deprecated (PEP 702).

Parameters:

  • kind ¤

    (str, default: 'danger' ) –

    Admonitions kind.

  • title ¤

    (str | None, default: 'Deprecated' ) –

    Admonitions title.

  • label ¤

    (str | None, default: 'deprecated' ) –

    Label added to deprecated objects.

Methods:

Attributes:

  • kind

    The kind of the admonition to insert in the docstring.

  • label

    The label added to deprecated objects.

  • title

    The title of the admonition to insert in the docstring.

Source code in src/griffe_warnings_deprecated/_internal/extension.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def __init__(
    self,
    kind: str = "danger",
    title: str | None = "Deprecated",
    label: str | None = "deprecated",
) -> None:
    """Initialize the extension.

    Parameters:
        kind: Admonitions kind.
        title: Admonitions title.
        label: Label added to deprecated objects.
    """
    super().__init__()
    self.kind = kind
    """The kind of the admonition to insert in the docstring."""
    self.title = title or ""
    """The title of the admonition to insert in the docstring."""
    self.label = label
    """The label added to deprecated objects."""

kind instance-attribute ¤

kind = kind

The kind of the admonition to insert in the docstring.

label instance-attribute ¤

label = label

The label added to deprecated objects.

title instance-attribute ¤

title = title or ''

The title of the admonition to insert in the docstring.

on_class_instance ¤

on_class_instance(*, cls: Class, **kwargs: Any) -> None

Add section to docstrings of deprecated classes.

Source code in src/griffe_warnings_deprecated/_internal/extension.py
61
62
63
64
65
66
67
def on_class_instance(self, *, cls: Class, **kwargs: Any) -> None:  # noqa: ARG002
    """Add section to docstrings of deprecated classes."""
    if message := _deprecated(cls):
        cls.deprecated = message
        self._insert_message(cls, message)
        if self.label:
            cls.labels.add(self.label)

on_function_instance ¤

on_function_instance(
    *, func: Function, **kwargs: Any
) -> None

Add section to docstrings of deprecated functions.

Source code in src/griffe_warnings_deprecated/_internal/extension.py
69
70
71
72
73
74
75
def on_function_instance(self, *, func: Function, **kwargs: Any) -> None:  # noqa: ARG002
    """Add section to docstrings of deprecated functions."""
    if message := _deprecated(func):
        func.deprecated = message
        self._insert_message(func, message)
        if self.label:
            func.labels.add(self.label)