Skip to content

Commit d4e2ea8

Browse files
committed
Use ruff instead of flake8, black and isort
1 parent d32abc8 commit d4e2ea8

10 files changed

Lines changed: 21 additions & 69 deletions

File tree

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,11 @@ jobs:
4141
python -m pip install --upgrade pip
4242
python -m pip install --upgrade tox
4343
44-
- name: Lint (flake8)
45-
run: flake8
44+
- name: Ruff format
45+
run: ruff format .
4646

47-
- name: Lint (black)
48-
run: black --check .
49-
50-
- name: Lint (isort)
51-
run: isort --check .
52-
53-
# - name: Lint (mypy)
54-
# run: mypy .
47+
- name: Ruff format
48+
run: ruff check .
5549

5650
- name: Unit tests
5751
run: |

.pre-commit-config.yaml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
31
repos:
4-
- repo: https://github.com/psf/black
5-
rev: 24.3.0
6-
hooks:
7-
- id: black
8-
# nice but doesn't support sphinx syntax - see https://github.com/Lucas-C/pre-commit-hooks-markup/issues/13
9-
# - repo: https://github.com/Lucas-C/pre-commit-hooks-markup
10-
# rev: v1.0.1
11-
# hooks:
12-
# - id: rst-linter
13-
- repo: https://github.com/pycqa/isort
14-
rev: 5.13.2
15-
hooks:
16-
- id: isort
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.14.7
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

pyproject.toml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ dependencies = [
3838

3939
[project.optional-dependencies]
4040
lint = [
41-
"isort >= 5",
42-
"flake8",
43-
"black",
44-
"mypy"
41+
"ruff",
4542
]
4643

4744
[project.urls]
@@ -50,13 +47,6 @@ homepage = "https://github.com/thisch/pytest-sphinx"
5047
[project.entry-points."pytest11"]
5148
"sphinx" = "pytest_sphinx"
5249

53-
[tool.isort]
54-
profile = "black"
55-
56-
[tool.mypy]
57-
strict = true
58-
warn_unused_ignores = false # mypy#8823
59-
6050
[build-system]
6151
requires = ["setuptools"]
6252
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/pytest_sphinx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ def _DocTestRunner__run(
383383

384384
# Process each example.
385385
for examplenum, example in enumerate(test.examples):
386-
387386
# If REPORT_ONLY_FIRST_FAILURE is set, then suppress
388387
# reporting after the first failure.
389388
quiet = (

tests/test_doc2test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def test_simple(in_between_content: str) -> None:
2020
2121
{{'3': 4,
2222
'5': 6}}
23-
""".format(
24-
in_between_content
25-
)
23+
""".format(in_between_content)
2624

2725
examples = docstring2examples(doc)
2826
assert len(examples) == 1

tests/test_options.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def test_skipif_and_text(expr: str, with_options: bool) -> None:
9292
9393
abcedf
9494
abcedf
95-
""".format(
96-
expr
97-
)
95+
""".format(expr)
9896
)
9997
if with_options:
10098
want = "\n:options: +NORMALIZE_WHITESPACE" + want

tests/test_python_files.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
def test_syntax_error_in_module_doctest(testdir: Testdir) -> None:
7-
87
testdir.makepyfile(
98
textwrap.dedent(
109
"""
@@ -28,7 +27,6 @@ def test_syntax_error_in_module_doctest(testdir: Testdir) -> None:
2827

2928

3029
def test_failing_module_doctest(testdir: Testdir) -> None:
31-
3230
testdir.makepyfile(
3331
textwrap.dedent(
3432
"""
@@ -82,7 +80,6 @@ def func():
8280

8381

8482
def test_working_module_doctest(testdir: Testdir) -> None:
85-
8683
testdir.makepyfile(
8784
textwrap.dedent(
8885
"""
@@ -129,7 +126,6 @@ def func():
129126

130127

131128
def test_working_module_doctest_nospaces(testdir: Testdir) -> None:
132-
133129
testdir.makepyfile(
134130
textwrap.dedent(
135131
"""
@@ -149,7 +145,6 @@ def test_working_module_doctest_nospaces(testdir: Testdir) -> None:
149145

150146

151147
def test_multiple_doctests_in_single_file(testdir: Testdir) -> None:
152-
153148
testdir.makepyfile(
154149
textwrap.dedent(
155150
"""

tests/test_sphinx_doctest.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Run tests that call "sphinx-build -M doctest". """
1+
"""Run tests that call "sphinx-build -M doctest"."""
22

33
import logging
44
import os
@@ -72,7 +72,6 @@ def sphinx_tester(tmpdir: LocalPath) -> Iterator[SphinxDoctestRunner]:
7272

7373

7474
def test_simple_doctest_failure(sphinx_tester: SphinxDoctestRunner) -> None:
75-
7675
output = sphinx_tester(
7776
"""
7877
===!!!
@@ -189,9 +188,7 @@ def test_skipif_true(
189188
:skipif: True
190189
191190
NOT EVALUATED
192-
""".format(
193-
testcode
194-
)
191+
""".format(testcode)
195192

196193
raise_in_testcode = testcode != "pass"
197194
sphinx_output = sphinx_tester(code, must_raise=raise_in_testcode)
@@ -222,9 +219,7 @@ def test_skipif_false(
222219
:skipif: False
223220
224221
EVALUATED
225-
""".format(
226-
testcode
227-
)
222+
""".format(testcode)
228223

229224
expected_failure = "EVALUATED" not in testcode
230225

@@ -264,9 +259,7 @@ def test_skipif_multiple_testoutput(
264259
Traceback (most recent call last):
265260
...
266261
{}
267-
""".format(
268-
"ValueError" if wrong_output_assertion else "RuntimeError"
269-
)
262+
""".format("ValueError" if wrong_output_assertion else "RuntimeError")
270263

271264
# -> ignore all skipped testoutput sections, but use the one that is
272265
# -> not skipped
@@ -296,9 +289,7 @@ def test_skipif_true_in_testcode(
296289
:skipif: False
297290
298291
NOT EVALUATED
299-
""".format(
300-
testcode
301-
)
292+
""".format(testcode)
302293

303294
sphinx_output = sphinx_tester(code, must_raise=False)
304295
assert "0 tests" in sphinx_output

0 commit comments

Comments
 (0)