Skip to content

Commit eff10cc

Browse files
committed
refactor: Update code for Griffe 0.48 (removing deprecation warnings)
Issue-173: mkdocstrings#173
1 parent bb85ad3 commit eff10cc

35 files changed

+53
-50
lines changed

config/pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ filterwarnings =
1212
error
1313
# TODO: remove once pytest-xdist 4 is released
1414
ignore:.*rsyncdir:DeprecationWarning:xdist
15+
# TODO: remove once Griffe releases v1
16+
ignore:.*`get_logger`:DeprecationWarning:_griffe
17+
ignore:.*`name`:DeprecationWarning:_griffe

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ classifiers = [
3030
]
3131
dependencies = [
3232
"mkdocstrings>=0.25",
33-
"griffe>=0.47",
33+
"griffe>=0.48",
3434
]
3535

3636
[project.urls]

src/mkdocstrings_handlers/python/handler.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
from pathlib import Path
1313
from typing import TYPE_CHECKING, Any, BinaryIO, ClassVar, Iterator, Mapping, Sequence
1414

15-
from griffe.collections import LinesCollection, ModulesCollection
16-
from griffe.docstrings.parsers import Parser
17-
from griffe.exceptions import AliasResolutionError
18-
from griffe.extensions import load_extensions
19-
from griffe.loader import GriffeLoader
20-
from griffe.logger import patch_loggers
15+
from griffe import (
16+
AliasResolutionError,
17+
GriffeLoader,
18+
LinesCollection,
19+
ModulesCollection,
20+
Parser,
21+
load_extensions,
22+
patch_logger,
23+
)
2124
from mkdocstrings.extension import PluginError
2225
from mkdocstrings.handlers.base import BaseHandler, CollectionError, CollectorItem
2326
from mkdocstrings.inventory import Inventory
@@ -47,7 +50,7 @@ def chdir(path: str) -> Iterator[None]: # noqa: D103
4750

4851
logger = get_logger(__name__)
4952

50-
patch_loggers(get_logger)
53+
patch_logger(get_logger)
5154

5255

5356
class PythonHandler(BaseHandler):

src/mkdocstrings_handlers/python/rendering.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
from pathlib import Path
1313
from typing import TYPE_CHECKING, Any, Callable, Match, Pattern, Sequence
1414

15-
from griffe.dataclasses import Alias, Object
16-
from griffe.docstrings.dataclasses import (
15+
from griffe import (
16+
Alias,
1717
DocstringSectionAttributes,
1818
DocstringSectionClasses,
1919
DocstringSectionFunctions,
2020
DocstringSectionModules,
21+
Object,
2122
)
2223
from jinja2 import TemplateNotFound, pass_context, pass_environment
2324
from markupsafe import Markup
2425
from mkdocstrings.loggers import get_logger
2526

2627
if TYPE_CHECKING:
27-
from griffe.dataclasses import Attribute, Class, Function, Module
28+
from griffe import Attribute, Class, Function, Module
2829
from jinja2 import Environment, Template
2930
from jinja2.runtime import Context
3031
from mkdocstrings.handlers.base import CollectorItem
@@ -364,11 +365,9 @@ def _keep_object(name: str, filters: Sequence[tuple[Pattern, bool]]) -> bool:
364365
if regex.search(name):
365366
keep = not exclude
366367
if keep is None:
367-
if rules == {False}:
368-
# only included stuff, no match = reject
369-
return False
370-
# only excluded stuff, or included and excluded stuff, no match = keep
371-
return True
368+
# When we only include stuff, no match = reject.
369+
# When we only exclude stuff, or include and exclude stuff, no match = keep.
370+
return rules != {False}
372371
return keep
373372

374373

src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This template renders a Python attribute (or variable).
44
This can be a module attribute or a class attribute.
55
66
Context:
7-
attribute (griffe.dataclasses.Attribute): The attribute to render.
7+
attribute (griffe.Attribute): The attribute to render.
88
root (bool): Whether this is the root object, injected with `:::` in a Markdown page.
99
heading_level (int): The HTML heading level to use.
1010
config (dict): The configuration options.

src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This template iterates on members of a given object and renders them.
44
It can group members by category (attributes, classes, functions, modules) or render them in a flat list.
55
66
Context:
7-
obj (griffe.dataclasses.Object): The object to render.
7+
obj (griffe.Object): The object to render.
88
config (dict): The configuration options.
99
root_members (bool): Whether the object is the root object.
1010
heading_level (int): The HTML heading level to use.

src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This template renders a Python class.
44
55
Context:
6-
class (griffe.dataclasses.Class): The class to render.
6+
class (griffe.Class): The class to render.
77
root (bool): Whether this is the root object, injected with `:::` in a Markdown page.
88
heading_level (int): The HTML heading level to use.
99
config (dict): The configuration options.

src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Griffe parses docstrings into a list of sections, each with a `kind` and a `valu
55
This template can then iterate on these sections and render them according to the configuration.
66
77
Context:
8-
docstring_sections (list[griffe.docstrings.dataclasses.DocstringSection]): The list of docstring sections.
8+
docstring_sections (list[griffe.DocstringSection]): The list of docstring sections.
99
config (dict): The configuration dictionary.
1010
heading_level (int): The heading level to use for Markdown conversion.
1111
html_id (str): The HTML ID to use for Markdown conversion.

src/mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This template renders admonitions using the `details` HTML element.
44
55
Context:
6-
section (griffe.docstrings.dataclasses.DocstringSectionAdmonition): The section to render.
6+
section (griffe.DocstringSectionAdmonition): The section to render.
77
-#}
88

99
{% block logs scoped %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This template renders a list of documented attributes in the format
44
specified with the [`docstring_section_style`][] configuration option.
55
66
Context:
7-
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
7+
section (griffe.DocstringSectionAttributes): The section to render.
88
-#}
99

1010
{% block logs scoped %}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy