8000 refactor: Update code for Griffe 0.48 (removing deprecation warnings) · thomasmarwitz/python@eff10cc · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.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 classes 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.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 examples.
44
It alternates between rendering text and code examples.
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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.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 functions 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.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 modules 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.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 other parameters 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.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 parameters 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.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 exceptions 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/receives.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 received values (generators) in the f
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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.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 returned values 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/warns.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 warnings 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 %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/yields.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 yielded values (generators) in the fo
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 %}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ which is a tree-like structure representing a Python expression.
1717
This macro outputs a cross-reference to the given name.
1818
1919
Parameters:
20-
name (griffe.expressions.ExprName): The name to cross-reference.
20+
name (griffe.ExprName): The name to cross-reference.
2121
annotation_path (str): Either "brief", "source", or "full".
2222
2323
Returns:
@@ -48,7 +48,7 @@ which is a tree-like structure representing a Python expression.
4848
{#- Render an expression.
4949
5050
Parameters:
51-
expression (griffe.expressions.Expr): The expression to render.
51+
expression (griffe.Expr): The expression to render.
5252
annotations_path (str): Either "brief", "source", or "full".
5353
5454
Returns:

src/mkdocstrings_handlers/python/templates/material/_base/function.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 function or method.
44
55
Context:
6-
function (griffe.dataclasses.Function): The function to render.
6+
function (griffe.Function): The function 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/module.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 module.
44
55
Context:
6-
module (griffe.dataclasses.Module): The module to render.
6+
module (griffe.Module): The module 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/signature.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ It iterates over the parameters of the function to rebuild the signature.
55
The signature is the list of parameters of a function or method, including their names, default values, and annotations.
66
77
Context:
8-
function (griffe.dataclasses.Function): The function or method to render.
8+
function (griffe.Function): The function or method to render.
99
config (dict): The configuration options.
1010
-#}
1111

src/mkdocstrings_handlers/python/templates/readthedocs/_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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.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 other parameters 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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.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 parameters 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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.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 exceptions 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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.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 received values (generators) in the f
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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.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 returned values 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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.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 warnings 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 %}

src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.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 yielded values (generators) in the fo
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 %}

tests/test_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from typing import TYPE_CHECKING
99

1010
import pytest
11-
from griffe.docstrings.dataclasses import DocstringSectionExamples, DocstringSectionKind
12-
from griffe.tests import temporary_visited_module
11+
from griffe import DocstringSectionExamples, DocstringSectionKind, temporary_visited_module
1312

1413
from mkdocstrings_handlers.python.handler import CollectionError, PythonHandler, get_handler
1514

tests/test_rendering.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from typing import TYPE_CHECKING, Any
88

99
import pytest
10-
from griffe.collections import ModulesCollection
11-
from griffe.tests import temporary_visited_module
10+
from griffe import ModulesCollection, temporary_visited_module
1211

1312
from mkdocstrings_handlers.python import rendering
1413

0 commit comments

Comments
 (0)
0