From 5cfc8427b782392de8a46ed6510f99aac3396283 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 26 Nov 2026 14:12:33 +0000 Subject: [PATCH 1/2] Render deprecations in the API documentation Enable the griffe-frequenz-core deprecations extension and add the style for its "Deprecated" admonition, as the repository configuration template does. The extension marks symbols deprecated with typing_extensions.deprecated and makes the strict documentation build fail when one has no notice. This way, the notices of upcoming deprecations, like the ones of the old resampler configurations, are rendered and checked. Signed-off-by: Leandro Lucarella --- docs/_css/mkdocstrings.css | 22 ++++++++++++++++++++++ mkdocs.yml | 2 ++ pyproject.toml | 1 + 3 files changed, 25 insertions(+) diff --git a/docs/_css/mkdocstrings.css b/docs/_css/mkdocstrings.css index 572abff13..851214f26 100644 --- a/docs/_css/mkdocstrings.css +++ b/docs/_css/mkdocstrings.css @@ -42,3 +42,25 @@ a.autorefs-external::after { a.autorefs-external:hover::after { background-color: var(--md-accent-fg-color); } + +/* A "Deprecated" admonition, styled like a warning but with its own icon. */ +:root { + --md-admonition-icon--deprecated: url('data:image/svg+xml;charset=utf-8,'); +} + +.md-typeset .admonition.deprecated, +.md-typeset details.deprecated { + border-color: #cc9900; +} + +.md-typeset .deprecated > .admonition-title, +.md-typeset .deprecated > summary { + background-color: #cc99001a; +} + +.md-typeset .deprecated > .admonition-title::before, +.md-typeset .deprecated > summary::before { + background-color: #cc9900; + -webkit-mask-image: var(--md-admonition-icon--deprecated); + mask-image: var(--md-admonition-icon--deprecated); +} diff --git a/mkdocs.yml b/mkdocs.yml index 83005355f..3c25ee03e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -103,6 +103,8 @@ plugins: python: paths: ["src"] options: + extensions: + - griffe_frequenz_core.deprecations docstring_section_style: spacy inherited_members: true merge_init_into_class: false diff --git a/pyproject.toml b/pyproject.toml index 114b99b4f..5e5cca1de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ dev-flake8 = [ dev-formatting = ["black == 26.10.1", "isort == 9.0.2"] dev-mkdocs = [ "black == 26.10.1", + "griffe-frequenz-core == 1.1.0", "Markdown==3.11.2", "mike == 2.2.0", "mkdocs-gen-files == 0.6.1", From d3e9d38273962beb6e14e6bebc705cee2e736f9a Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 26 Nov 2026 14:14:46 +0000 Subject: [PATCH 2/2] Make the SDK's own deprecations fail the tests Deprecations coming from dependencies are still reported only once, but using a symbol the SDK deprecated itself is now an error, so the SDK doesn't ship code that still uses it, which users would see as warnings they can do nothing about. This is the filter the repository configuration template generates. Signed-off-by: Leandro Lucarella --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5e5cca1de..522e26b36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,6 +181,14 @@ filterwarnings = [ "error", "once::DeprecationWarning", "once::PendingDeprecationWarning", + # But using our own deprecated symbols is an error, so we don't release code + # still using our own deprecated symbols, which will be noise for users. + # This is only a heuristic: it catches deprecation messages mentioning the + # fully qualified name of the deprecated symbol, as in "frequenz.sdk.OldThing + # is deprecated. Use frequenz.sdk.NewThing instead.". This is the + # recommended style in the deprecation guide: + # https://github.com/frequenz-floss/docs/blob/v0.x.x/python/deprecations.md + 'error:.*frequenz\.sdk\.[\w\.]+ (is|was) deprecated:DeprecationWarning', # We need to ignore PytestUnraisableExceptionWarning because we have some # cleanup issues, and sometimes exceptions are raised in __del__ methods, for # example when trying to do async stuff and the event loop is already closed.