Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"
dependencies = ["pytest>=7", "black>=23", "ruff>=0.5.0"]
dependencies = ["pytest>=7", "black>=23", "ruff>=0.12.9"]

[project.entry-points.pytest11]
examples = "pytest_examples"
Expand Down
4 changes: 2 additions & 2 deletions pytest_examples/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def ruff_check(

def replace_offset(m: re.Match[str]):
line_number = int(m.group(1))
return f'{example.path}:{line_number + example.start_line}'
return f' --> {example.path}:{line_number + example.start_line}'

output = re.sub(r'^-:(\d+)', replace_offset, stdout, flags=re.M)
output = re.sub(r'^ --> -:(\d+)', replace_offset, stdout, flags=re.M)
raise FormatError(f'ruff failed:\n{indent(output, " ")}')
elif p.returncode != 0:
raise RuntimeError(f'Error running ruff, return code {p.returncode}:\n{stderr or stdout}')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_ruff_config():
def test_ruff_offset():
code = 'print(x)\n'
example = CodeExample.create(code)
with pytest.raises(FormatError, match='testing.md:1:7: F821 Undefined name'):
with pytest.raises(FormatError, match='F821 Undefined name `x`\n --> testing.md:1:7'):
ruff_check(example, ExamplesConfig())

example = CodeExample.create(code, start_line=10)
with pytest.raises(FormatError, match='testing.md:11:7: F821 Undefined name'):
with pytest.raises(FormatError, match='F821 Undefined name `x`\n --> testing.md:11:7'):
ruff_check(example, ExamplesConfig())


Expand Down
4 changes: 2 additions & 2 deletions tests/test_run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
'=== FAILURES ===\n',
'___ test_find_run_examples[my_file.md:1-4] ___\n',
'ruff failed:\n',
' my_file.md:2:8: F401 [*] `sys` imported but unused\n',
' my_file.md:3:7: F821 Undefined name `missing`\n',
' F401 [*] `sys` imported but unused\n --> my_file.md:2:8\n',
' F821 Undefined name `missing`\n --> my_file.md:3:7\n',
' Found 2 errors.\n',
' [*] 1 fixable with the `--fix` option.\n',
'=== short test summary info ===\n',
Expand Down
43 changes: 22 additions & 21 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading