Skip to content

Commit d70fed2

Browse files
authored
Update to repo-config v0.13 (#1186)
We now also treat warnings as errors, although we had to make one exception because of the clean-up issues we have in the SDK.
2 parents 87c2e35 + 375ed90 commit d70fed2

File tree

5 files changed

+55
-94
lines changed

5 files changed

+55
-94
lines changed

.github/dependabot.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,50 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# We group production and development ("optional" in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
2829
exclude-patterns:
29-
- "frequenz-client-microgrid*"
30-
optional:
31-
dependency-type: "development"
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3233
update-types:
3334
- "minor"
34-
- "patch"
35-
in-devel-patch:
35+
exclude-patterns:
36+
- "async-solipsism"
37+
- "frequenz-client-microgrid"
38+
- "frequenz-repo-config*"
39+
- "markdown-callouts"
40+
- "mkdocs-gen-files"
41+
- "mkdocs-literate-nav"
42+
- "mkdocstrings*"
43+
- "pydoclint"
44+
- "pytest-asyncio"
45+
# We group repo-config updates as it uses optional dependencies that are
46+
# considered different dependencies otherwise, and will create one PR for
47+
# each if we don't group them.
48+
repo-config:
3649
patterns:
37-
- "frequenz-client-microgrid*"
38-
dependency-type: "production"
39-
update-types:
40-
- "patch"
50+
- "frequenz-repo-config*"
51+
mkdocstrings:
52+
patterns:
53+
- "mkdocstrings*"
4154
ignore:
4255
# Upgrade to time-machine 2.13.0+ breaks our tests. See:
4356
# https://github.com/frequenz-floss/frequenz-sdk-python/issues/832
4457
- dependency-name: "time-machine"
4558
versions: [">=2.13.0"]
46-
# Upgrading to 0.16.0+ needs a lot of changes in the code. See:
47-
# https://github.com/frequenz-floss/frequenz-sdk-python/issues/844
48-
- dependency-name: "frequenz-api-microgrid"
49-
versions: [">=0.16.0"]
59+
5060

5161

5262
- package-ecosystem: "github-actions"

.github/workflows/ci-pr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Test PR
22

3-
on: pull_request
3+
on:
4+
pull_request:
45

56
env:
67
# Please make sure this version is included in the `matrix`, as the
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ jobs:
4747
- name: Run nox
4848
uses: frequenz-floss/[email protected]
4949
with:
50-
git-username: ${{ secrets.GIT_USER }}
51-
git-password: ${{ secrets.GIT_PASS }}
5250
python-version: ${{ matrix.python }}
5351
nox-session: ${{ matrix.nox-session }}
5452

docs/_scripts/macros.py

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,12 @@
55

66
import os
77
import pathlib
8-
from typing import Any
98

10-
import markdown as md
11-
from markdown.extensions import toc
12-
from mkdocs_macros import plugin as macros
13-
14-
_CODE_ANNOTATION_MARKER: str = (
15-
r'<span class="md-annotation">'
16-
r'<span class="md-annotation__index" tabindex="-1">'
17-
r'<span data-md-annotation-id="1"></span>'
18-
r"</span>"
19-
r"</span>"
9+
from frequenz.repo.config.mkdocs.mkdocstrings_macros import (
10+
hook_env_with_everything,
11+
slugify,
2012
)
21-
22-
23-
def _slugify(text: str) -> str:
24-
"""Slugify a text.
25-
26-
Args:
27-
text: The text to slugify.
28-
29-
Returns:
30-
The slugified text.
31-
"""
32-
return toc.slugify_unicode(text, "-")
33-
34-
35-
def _hook_macros_plugin(env: macros.MacrosPlugin) -> None:
36-
"""Integrate the `mkdocs-macros` plugin into `mkdocstrings`.
37-
38-
This is a temporary workaround to make `mkdocs-macros` work with
39-
`mkdocstrings` until a proper `mkdocs-macros` *pluglet* is available. See
40-
https://github.com/mkdocstrings/mkdocstrings/issues/615 for details.
41-
42-
Args:
43-
env: The environment to hook the plugin into.
44-
"""
45-
# get mkdocstrings' Python handler
46-
python_handler = env.conf["plugins"]["mkdocstrings"].get_handler("python")
47-
48-
# get the `update_env` method of the Python handler
49-
update_env = python_handler.update_env
50-
51-
# override the `update_env` method of the Python handler
52-
def patched_update_env(markdown: md.Markdown, config: dict[str, Any]) -> None:
53-
update_env(markdown, config)
54-
55-
# get the `convert_markdown` filter of the env
56-
convert_markdown = python_handler.env.filters["convert_markdown"]
57-
58-
# build a chimera made of macros+mkdocstrings
59-
def render_convert(markdown: str, *args: Any, **kwargs: Any) -> Any:
60-
return convert_markdown(env.render(markdown), *args, **kwargs)
61-
62-
# patch the filter
63-
python_handler.env.filters["convert_markdown"] = render_convert
64-
65-
# patch the method
66-
python_handler.update_env = patched_update_env
13+
from mkdocs_macros import plugin as macros
6714

6815

6916
def define_env(env: macros.MacrosPlugin) -> None:
@@ -72,9 +19,6 @@ def define_env(env: macros.MacrosPlugin) -> None:
7219
Args:
7320
env: The environment to define the macro functions in.
7421
"""
75-
# A variable to easily show an example code annotation from mkdocs-material.
76-
# https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#adding-annotations
77-
env.variables["code_annotation_marker"] = _CODE_ANNOTATION_MARKER
7822

7923
@env.macro # type: ignore[misc]
8024
def glossary(term: str, text: str | None = None) -> str:
@@ -94,7 +38,7 @@ def glossary(term: str, text: str | None = None) -> str:
9438
# always the case, for example when referencing the glossary from the API
9539
# reference.
9640
link_path = os.path.relpath(glossary_path, current_path.parent)
97-
return f"[{text or term}]({link_path}#{_slugify(term)})"
41+
return f"[{text or term}]({link_path}#{slugify(term)})"
9842

99-
# This hook needs to be done at the end of the `define_env` function.
100-
_hook_macros_plugin(env)
43+
# This must be at the end to enable all standard features
44+
hook_env_with_everything(env)

pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
requires = [
66
"setuptools == 75.8.0",
77
"setuptools_scm[toml] == 8.1.0",
8-
"frequenz-repo-config[lib] == 0.11.0",
8+
"frequenz-repo-config[lib] == 0.13.2",
99
]
1010
build-backend = "setuptools.build_meta"
1111

@@ -61,9 +61,9 @@ dev-mkdocs = [
6161
"mkdocs-literate-nav == 0.6.1",
6262
"mkdocs-macros-plugin == 1.3.7",
6363
"mkdocs-material == 9.6.1",
64-
"mkdocstrings[python] == 0.27.0",
65-
"mkdocstrings-python == 1.13.0",
66-
"frequenz-repo-config[lib] == 0.11.0",
64+
"mkdocstrings[python] == 0.29.1",
65+
"mkdocstrings-python == 1.16.10",
66+
"frequenz-repo-config[lib] == 0.13.2",
6767
]
6868
dev-mypy = [
6969
"mypy == 1.14.1",
@@ -73,15 +73,15 @@ dev-mypy = [
7373
# For checking the noxfile, docs/ script, and tests
7474
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
7575
]
76-
dev-noxfile = ["nox == 2025.2.9", "frequenz-repo-config[lib] == 0.11.0"]
76+
dev-noxfile = ["nox == 2025.2.9", "frequenz-repo-config[lib] == 0.13.2"]
7777
dev-pylint = [
7878
"pylint == 3.3.4",
7979
# For checking the noxfile, docs/ script, and tests
8080
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
8181
]
8282
dev-pytest = [
8383
"pytest == 8.3.4",
84-
"frequenz-repo-config[extra-lint-examples] == 0.11.0",
84+
"frequenz-repo-config[extra-lint-examples] == 0.13.2",
8585
"pytest-mock == 3.14.0",
8686
"pytest-asyncio == 0.25.3",
8787
"time-machine == 2.12.0",
@@ -163,6 +163,14 @@ disable = [
163163
max-attributes = 12
164164

165165
[tool.pytest.ini_options]
166+
# We need to ignore PytestUnraisableExceptionWarning because we have some
167+
# cleanup issues, and sometimes exceptions are raised in __del__ methods, for
168+
# example when trying to do async stuff and the event loop is already closed.
169+
# This could even be caused by the GC, some time after the test function that
170+
# has the issue was completed.
171+
# Please see this issue for more details:
172+
# https://github.com/frequenz-floss/frequenz-sdk-python/issues/982
173+
addopts = "-W=all -Werror -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -Wdefault::pytest.PytestUnraisableExceptionWarning -vv"
166174
testpaths = ["tests", "src"]
167175
asyncio_mode = "auto"
168176
asyncio_default_fixture_loop_scope = "function"

0 commit comments

Comments
 (0)