Skip to content

Commit e2bae45

Browse files
authored
Update pytest and sybil (#221)
fixes #219
2 parents f479301 + 4b09189 commit e2bae45

File tree

10 files changed

+17
-19
lines changed

10 files changed

+17
-19
lines changed

RELEASE_NOTES.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
- Once you upgraded, you'll be able to upgrade to `pytest` 8, and indirectly to `sybil` 6, which includes types hints. If you do so, you should remove the `mypy` exception for `sybil` in the `pyproject.toml` file.
10+
11+
Search for the `tool.mypy.overrides` section and remove the `"sybil", "sybil.*"` enties from the `module` list.
1012

1113
### Cookiecutter template
1214

@@ -86,7 +88,7 @@ To upgrade without regenerating the project, you can follow these steps:
8688
8789
## New Features
8890
89-
<!-- Here goes the main new features and examples or instructions on how to use them -->
91+
- Add support for `pytest` 8.
9092
9193
### Cookiecutter template
9294

cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ dev-pylint = [
9898
"{{cookiecutter.pypi_package_name}}[dev-mkdocs,dev-noxfile,dev-pytest]",
9999
]
100100
dev-pytest = [
101-
"pytest == 7.4.2",
101+
"pytest == 8.0.0",
102102
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
103103
{%- if cookiecutter.type != "api" %}
104104
"pytest-mock == 3.11.1",

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ lib = []
6363
model = []
6464
extra-lint-examples = [
6565
"pylint >= 2.17.3, < 4",
66-
"pytest >= 7.3.0, < 8",
67-
"sybil >= 5.0.3, < 6",
66+
"pytest >= 7.3.0, < 9",
67+
"sybil >= 5.0.3, < 7",
6868
]
6969
dev-flake8 = [
7070
"flake8 == 6.1.0",
@@ -101,11 +101,11 @@ dev-pylint = [
101101
"frequenz-repo-config[dev-mkdocs,dev-noxfile,dev-pytest]",
102102
]
103103
dev-pytest = [
104-
"pytest == 7.4.2",
104+
"pytest == 8.0.0",
105105
"pylint == 3.0.2", # We need this to check for the examples
106106
"cookiecutter == 2.1.1", # For checking the cookiecutter scripts
107107
"jinja2 == 3.1.2", # For checking the cookiecutter scripts
108-
"sybil == 5.0.3", # Should be consistent with the extra-lint-examples dependency
108+
"sybil == 6.0.3", # Should be consistent with the extra-lint-examples dependency
109109
]
110110
dev = [
111111
"frequenz-repo-config[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
@@ -188,8 +188,6 @@ module = [
188188
"github_action_utils",
189189
"mkdocs_macros.*",
190190
"semver.version",
191-
"sybil",
192-
"sybil.*",
193191
]
194192
ignore_missing_imports = true
195193

src/frequenz/repo/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
"my-package[dev-mkdocs,dev-pytest]",
165165
]
166166
dev-pytest = [
167-
"pytest == 7.2.2",
167+
"pytest == 8.0.0",
168168
"pytest-asyncio == 0.21.0",
169169
"pytest-mock == 3.10.0",
170170
]

src/frequenz/repo/config/pytest/examples.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import ast
2626
import os
2727
import subprocess
28+
import textwrap
2829
from pathlib import Path
2930
from typing import Any
3031

3132
from sybil import Example
3233
from sybil.evaluators.python import pad
33-
from sybil.parsers.abstract.lexers import textwrap
3434
from sybil.parsers.myst import CodeBlockParser
3535

3636
_PYLINT_DISABLE_COMMENT = (
@@ -116,9 +116,7 @@ def _path_to_import_statement(path: Path) -> str:
116116
return import_statement
117117

118118

119-
# We need to add the type ignore comment here because the Sybil library does not
120-
# have type annotations.
121-
class _CustomPythonCodeBlockParser(CodeBlockParser): # type: ignore[misc]
119+
class _CustomPythonCodeBlockParser(CodeBlockParser):
122120
"""Code block parser that validates extracted code examples using pylint.
123121
124122
This parser is a modified version of the default Python code block parser

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dev-pylint = [
7777
"frequenz-actor-test[dev-mkdocs,dev-noxfile,dev-pytest]",
7878
]
7979
dev-pytest = [
80-
"pytest == 7.4.2",
80+
"pytest == 8.0.0",
8181
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
8282
"pytest-mock == 3.11.1",
8383
"pytest-asyncio == 0.21.1",

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ dev-pylint = [
7676
"frequenz-api-test[dev-mkdocs,dev-noxfile,dev-pytest]",
7777
]
7878
dev-pytest = [
79-
"pytest == 7.4.2",
79+
"pytest == 8.0.0",
8080
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
8181
]
8282
dev = [

tests_golden/integration/test_cookiecutter_generation/app/frequenz-app-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ dev-pylint = [
7676
"frequenz-app-test[dev-mkdocs,dev-noxfile,dev-pytest]",
7777
]
7878
dev-pytest = [
79-
"pytest == 7.4.2",
79+
"pytest == 8.0.0",
8080
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
8181
"pytest-mock == 3.11.1",
8282
"pytest-asyncio == 0.21.1",

tests_golden/integration/test_cookiecutter_generation/lib/frequenz-test-python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dev-pylint = [
7373
"frequenz-test[dev-mkdocs,dev-noxfile,dev-pytest]",
7474
]
7575
dev-pytest = [
76-
"pytest == 7.4.2",
76+
"pytest == 8.0.0",
7777
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
7878
"pytest-mock == 3.11.1",
7979
"pytest-asyncio == 0.21.1",

tests_golden/integration/test_cookiecutter_generation/model/frequenz-model-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dev-pylint = [
7777
"frequenz-model-test[dev-mkdocs,dev-noxfile,dev-pytest]",
7878
]
7979
dev-pytest = [
80-
"pytest == 7.4.2",
80+
"pytest == 8.0.0",
8181
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
8282
"pytest-mock == 3.11.1",
8383
"pytest-asyncio == 0.21.1",

0 commit comments

Comments
 (0)