Skip to content

Commit 48a778c

Browse files
committed
Adopt Ruff
1 parent 781815a commit 48a778c

File tree

8 files changed

+97
-42
lines changed

8 files changed

+97
-42
lines changed

.flake8

-3
This file was deleted.

.pre-commit-config.yaml

+4-33
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.15.2
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.3.7
44
hooks:
5-
- id: pyupgrade
6-
args: [--py39-plus]
7-
8-
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.4.0
10-
hooks:
11-
- id: black
12-
13-
- repo: https://github.com/PyCQA/isort
14-
rev: 5.13.2
15-
hooks:
16-
- id: isort
17-
files: \.py$
18-
args: ["--profile", "black"]
19-
20-
- repo: https://github.com/PyCQA/flake8
21-
rev: 7.0.0
22-
hooks:
23-
- id: flake8
5+
- id: ruff
6+
- id: ruff-format
247

258
- repo: https://github.com/pre-commit/pre-commit-hooks
269
rev: v4.6.0
@@ -34,15 +17,3 @@ repos:
3417
- id: end-of-file-fixer
3518
- id: forbid-new-submodules
3619
- id: trailing-whitespace
37-
38-
- repo: https://github.com/PyCQA/pydocstyle
39-
rev: 6.3.0
40-
hooks:
41-
- id: pydocstyle
42-
files: src/.*\.py$
43-
44-
- repo: https://github.com/asottile/blacken-docs
45-
rev: 1.16.0
46-
hooks:
47-
- id: blacken-docs
48-
additional_dependencies: [black==24.4.0]

.ruff.toml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
target-version = "py39" # Pin Ruff to Python 3.9
2+
line-length = 88
3+
output-format = "full"
4+
extend-exclude = [
5+
"noxfile.py",
6+
]
7+
8+
[lint]
9+
preview = true
10+
ignore = [
11+
"D100",
12+
"D101",
13+
"D102",
14+
"D103",
15+
"D105",
16+
"D107",
17+
"E203",
18+
# "W503", # unimplemented in Ruff (as of 2024-04-16)
19+
]
20+
select = [
21+
# flake8-builtins ('A')
22+
"A",
23+
# flake8-unused-arguments ('ARG')
24+
"ARG",
25+
# flake8-async ('ASYNC')
26+
"ASYNC",
27+
# flake8-bugbear ('B')
28+
"B",
29+
# flake8-comprehensions ('C4')
30+
"C4",
31+
# mccabe ('C90')
32+
"C901",
33+
# pydocstyle ('D')
34+
"D",
35+
# pycodestyle ('E')
36+
"E",
37+
# pyflakes ('F')
38+
"F",
39+
# isort ('I')
40+
"I",
41+
# pep8-naming ('N')
42+
"N",
43+
# perflint ('PERF')
44+
"PERF",
45+
# pygrep-hooks ('PGH')
46+
"PGH",
47+
# flake8-pytest-style ('PT')
48+
"PT",
49+
# flake8-quotes ('Q')
50+
"Q",
51+
# flake8-return ('RET')
52+
"RET",
53+
# flake8-raise ('RSE')
54+
"RSE",
55+
# flake8-simplify ('SIM')
56+
"SIM",
57+
# pyupgrade ('UP')
58+
"UP",
59+
# pycodestyle ('W')
60+
"W",
61+
]
62+
63+
[lint.pydocstyle]
64+
convention = "pep257"
65+
66+
[lint.per-file-ignores]
67+
"tests/*" = [
68+
"E501",
69+
"S101", # whitelist ``assert`` for tests
70+
"T201", # whitelist ``print`` for tests
71+
]
72+
73+
[lint.flake8-quotes]
74+
inline-quotes = "double"
75+
76+
[lint.isort]
77+
forced-separate = [
78+
"tests",
79+
]
80+
81+
[format]
82+
preview = true
83+
quote-style = "double"
84+
docstring-code-format = true

sphinx_autobuild/__main__.py

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def _get_sphinx_build_parser():
123123

124124
def _get_parser():
125125
"""Get the application's argument parser."""
126-
127126
parser = argparse.ArgumentParser(allow_abbrev=False)
128127
parser.add_argument(
129128
"--version", action="version", version=f"sphinx-autobuild {__version__}"

sphinx_autobuild/build.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __init__(self, sphinx_args, *, url_host, pre_build_commands):
1616

1717
def __call__(self, *, rebuild: bool = True):
1818
"""Generate the documentation using ``sphinx``."""
19-
2019
if rebuild:
2120
show(context="Detected change. Rebuilding...")
2221

sphinx_autobuild/filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __call__(self, path):
2727
return True
2828

2929
# Any regular expression matches.
30-
for regex in self.regex_based_patterns:
30+
for regex in self.regex_based_patterns: # NoQA: SIM110
3131
if regex.search(path):
3232
return True
3333

sphinx_autobuild/middleware.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from __future__ import annotations
22

3+
from typing import TYPE_CHECKING
4+
35
from starlette.datastructures import MutableHeaders
4-
from starlette.types import ASGIApp, Message, Receive, Scope, Send
6+
7+
if TYPE_CHECKING:
8+
from starlette.types import ASGIApp, Message, Receive, Scope, Send
59

610

711
def web_socket_script(ws_url: str) -> str:

sphinx_autobuild/server.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
import os
55
from concurrent.futures import ProcessPoolExecutor
66
from contextlib import AbstractAsyncContextManager, asynccontextmanager
7+
from typing import TYPE_CHECKING
78

89
import watchfiles
9-
from starlette.types import Receive, Scope, Send
1010
from starlette.websockets import WebSocket
1111

12-
TYPE_CHECKING = False
1312
if TYPE_CHECKING:
1413
from collections.abc import Callable
1514

15+
from starlette.types import Receive, Scope, Send
16+
1617
from sphinx_autobuild.filter import IgnoreFilter
1718

1819

0 commit comments

Comments
 (0)