File: griffe_exts.py

package info (click to toggle)
python-griffe 1.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,256 kB
  • sloc: python: 16,348; javascript: 84; makefile: 47; sh: 24
file content (24 lines) | stat: -rw-r--r-- 974 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# YORE: Bump 2: Remove file.

from typing import Any

import griffe


class ModuleGetAttrExtension(griffe.Extension):
    def on_package(self, *, pkg: griffe.Module, **kwargs: Any) -> None:  # noqa: ARG002,D102
        if pkg.name == "griffe":
            for name in griffe._deprecated_names:
                try:
                    target = pkg[f"_internal.git._{name}"]
                except KeyError:
                    # Old version where the utility was not yet renamed.
                    continue
                pkg.set_member(name, griffe.Alias(name, target=f"griffe._internal.git._{name}"))
                admonition = griffe.DocstringSectionAdmonition(
                    kind="danger",
                    text="",
                    title="This function is deprecated and will become unavailable in the next major version.",
                )
                target.docstring.parsed.insert(1, admonition)
                target.labels.add("deprecated")