Skip to content

Commit 5d84807

Browse files
llucaxstefan-brus-frequenz
authored andcommitted
Add a pytest hook to lint examples in docstrings
See frequenz-floss/frequenz-repo-config-python#27 for more details. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 178161f commit 5d84807

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

py/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Validate docstring code examples.
5+
6+
Code examples are often wrapped in triple backticks (```) within docstrings.
7+
This plugin extracts these code examples and validates them using pylint.
8+
"""
9+
10+
from frequenz.repo.config.pytest import examples
11+
from sybil import Sybil
12+
13+
pytest_collect_file = Sybil(**examples.get_sybil_arguments()).pytest()

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ dev-mypy = [
5252
]
5353
dev-noxfile = ["nox == 2022.11.21", "frequenz-repo-config[api] == 0.2.0"]
5454
dev-pylint = [
55-
"pylint == 2.17.1",
55+
"pylint == 2.17.3",
5656
# For checking the noxfile, docs/ script, and tests
5757
"frequenz-api-dispatch[dev-mkdocs,dev-noxfile,dev-pytest]",
5858
]
59-
dev-pytest = ["pytest == 7.2.2"]
59+
dev-pytest = [
60+
"pytest == 7.3.1",
61+
"frequenz-repo-config[extra-lint-examples] == 0.5.2",
62+
]
6063
dev = [
6164
"frequenz-api-dispatch[dev-mkdocs,dev-docstrings,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
6265
]

0 commit comments

Comments
 (0)