Skip to content

Commit 623a2c8

Browse files
Update ruff to 0.8.4
This introduces some new checks that are fixed in this commit as well. * pyproject.toml : Update ruff to 0.8.4 * poetry.lock : Automatic update. * .pre-commit-config.yaml : Sync ruff version with `poetry.lock` * run ruff on code base
1 parent e58db92 commit 623a2c8

File tree

10 files changed

+62
-62
lines changed

10 files changed

+62
-62
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ repos:
5555

5656
# Lint python code with ruff (also sorts imports)
5757
- repo: https://github.com/charliermarsh/ruff-pre-commit
58-
rev: "bbaf495f2dc6ce2853c91dc0b2c75d3b8249c15c" # frozen: v0.1.15
58+
rev: "f0b5944bef86f50d875305821a0ab0d8c601e465" # frozen: v0.8.4
5959
hooks:
6060
- id: ruff
6161
args: [--fix, --exit-non-zero-on-fix]

poetry.lock

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sphinx-polyversion = "sphinx_polyversion.main:main"
3838

3939
[tool.poetry.group.lint.dependencies]
4040
mypy = "^1.7.1"
41-
ruff = "^0.1.6"
41+
ruff = "^0.8.4"
4242
black = "^23.11.0"
4343

4444
[tool.poetry.group.test.dependencies]
@@ -79,7 +79,9 @@ ignore_missing_imports = true
7979

8080
[tool.ruff]
8181
target-version = "py38"
82+
line-length = 88 # Same as Black.
8283

84+
[tool.ruff.lint]
8385
select = [
8486
"T", # flake8-print
8587
"I", # isort
@@ -126,18 +128,15 @@ ignore = [
126128
"TD002", # missing author
127129
]
128130

129-
# Same as Black.
130-
line-length = 88
131-
132131
# Allow unused variables when underscore-prefixed or of form `dummyN`.
133132
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy\\d*)$"
134133

135134
# Less strict rules for docs/* and tests/*.
136-
[tool.ruff.per-file-ignores]
135+
[tool.ruff.lint.per-file-ignores]
137136
"docs/*" = ["PLR", "D1", "PTH", "INP"]
138137
"tests/*" = ["PLR2004"]
139138

140-
[tool.ruff.pylint]
139+
[tool.ruff.lint.pylint]
141140
# Allow more arguments for complexity check
142141
max-args = 8
143142

sphinx_polyversion/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from sphinx_polyversion.json import GLOBAL_DECODER, GLOBAL_ENCODER
1616

1717
__all__ = (
18+
"GLOBAL_DECODER",
19+
"GLOBAL_ENCODER",
20+
"DefaultDriver",
1821
"apply_overrides",
1922
"load",
2023
"order_versions",
21-
"DefaultDriver",
22-
"GLOBAL_DECODER",
23-
"GLOBAL_ENCODER",
2424
)
2525

2626
logger = getLogger(__name__)

sphinx_polyversion/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sphinx_polyversion.json import GLOBAL_DECODER
1010
from sphinx_polyversion.main import get_parser
1111

12-
__all__ = ["load", "apply_overrides"]
12+
__all__ = ["apply_overrides", "load"]
1313

1414

1515
class LoadError(RuntimeError):

sphinx_polyversion/driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
StrPath = Union[str, PathLike[str]]
4545

4646

47-
__all__ = ["Driver", "DefaultDriver"]
47+
__all__ = ["DefaultDriver", "Driver"]
4848

4949

5050
EXC_INFO = Tuple[Type[BaseException], BaseException, TracebackType]
@@ -508,7 +508,7 @@ def __init__(
508508
self.encoder = encoder or GLOBAL_ENCODER
509509
self.root_data_factory = root_data_factory
510510

511-
if isinstance(builder, dict) or isinstance(env, dict) and not selector:
511+
if isinstance(builder, dict) or (isinstance(env, dict) and not selector):
512512
raise ValueError(
513513
"Must provide selector if a mapping is passed for `builder` or `env`."
514514
)

sphinx_polyversion/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from sphinx_polyversion.utils import async_all
3434
from sphinx_polyversion.vcs import VersionProvider
3535

36-
__all__ = ["GitRef", "GitRefType", "Git", "file_predicate", "refs_by_type"]
36+
__all__ = ["Git", "GitRef", "GitRefType", "file_predicate", "refs_by_type"]
3737

3838
logger = getLogger(__name__)
3939

sphinx_polyversion/json.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
runtime_checkable,
2424
)
2525

26-
__all__ = ["Encoder", "Decoder", "RecursionWarning", "std_hook"]
26+
__all__ = ["Decoder", "Encoder", "RecursionWarning", "std_hook"]
2727

2828

2929
#: Python types representing a key in JSON mapping
@@ -226,7 +226,7 @@ def transform(self, o: JSONable) -> JSON_TYPE_DUMP:
226226
if hasattr(o, "_json_fields"):
227227
# type JSONable
228228
fields = o._json_fields() # type: ignore
229-
if t := type(o) == type(fields):
229+
if t := type(o) is type(fields):
230230
warnings.warn(
231231
f"Class {t} returns itself as json field container",
232232
RecursionWarning,
@@ -500,7 +500,7 @@ def fields(o: Any) -> None | JSONable:
500500
"""
501501

502502
@staticmethod
503-
def from_json(cls: str, o: JSON_TYPE) -> Any:
503+
def from_json(cls: str, o: JSON_TYPE) -> Any: # noqa: PLW0211
504504
"""
505505
Instanciate an object from its fields.
506506
@@ -550,7 +550,7 @@ def fields(o: Any) -> str | None:
550550
return None
551551

552552
@staticmethod
553-
def from_json(cls: str, o: JSON_TYPE) -> Any:
553+
def from_json(cls: str, o: JSON_TYPE) -> Any: # noqa: PLW0211
554554
"""Decode an object."""
555555
o = cast(str, o)
556556
return datetime.fromisoformat(o)

tests/test_git.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def no_git_env(_env: Mapping[str, str] | None = None) -> dict[str, str]:
7878
}
7979

8080

81-
@pytest.fixture()
81+
@pytest.fixture
8282
def git_testrepo(tmp_path: Path) -> Tuple[Path, List[GitRef]]:
8383
"""Create a git repository for testing."""
8484
git = ("git", *NO_FS_MONITOR)
@@ -162,13 +162,13 @@ def run_git(*args: str) -> None:
162162
return tmp_path, refs
163163

164164

165-
@pytest.fixture()
165+
@pytest.fixture
166166
def git() -> Git:
167167
"""Create a `Git` instance for testing."""
168168
return Git(branch_regex=".*", tag_regex=".*")
169169

170170

171-
@pytest.fixture()
171+
@pytest.fixture
172172
def git_with_predicate() -> Git:
173173
"""Create a `Git` instance with a predicate for testing."""
174174

@@ -182,13 +182,13 @@ async def predicate(root: Path, ref: GitRef) -> bool:
182182
)
183183

184184

185-
@pytest.fixture()
185+
@pytest.fixture
186186
def git_with_buffer_size() -> Git:
187187
"""Create a `Git` instance with a buffer size for testing."""
188188
return Git(branch_regex=".*", tag_regex=".*", buffer_size=1024)
189189

190190

191-
@pytest.mark.asyncio()
191+
@pytest.mark.asyncio
192192
async def test_aroot(git: Git, git_testrepo: Tuple[Path, List[GitRef]]):
193193
"""Test the `aroot` method."""
194194
repo_path, _ = git_testrepo
@@ -199,7 +199,7 @@ async def test_aroot(git: Git, git_testrepo: Tuple[Path, List[GitRef]]):
199199
assert root == repo_path
200200

201201

202-
@pytest.mark.asyncio()
202+
@pytest.mark.asyncio
203203
async def test_checkout(
204204
git: Git,
205205
git_testrepo: Tuple[Path, List[GitRef]],
@@ -211,7 +211,7 @@ async def test_checkout(
211211
assert (tmp_path / "test.txt").read_text() == "test"
212212

213213

214-
@pytest.mark.asyncio()
214+
@pytest.mark.asyncio
215215
async def test_checkout_with_buffer(
216216
git_with_buffer_size: Git,
217217
git_testrepo: Tuple[Path, List[GitRef]],
@@ -223,7 +223,7 @@ async def test_checkout_with_buffer(
223223
assert (tmp_path / "test.txt").read_text() == "test"
224224

225225

226-
@pytest.mark.asyncio()
226+
@pytest.mark.asyncio
227227
async def test_predicate(git_with_predicate: Git):
228228
"""Test the `predicate` method."""
229229
root = "."
@@ -248,7 +248,7 @@ def compare_refs(ref1: GitRef, ref2: GitRef) -> bool:
248248
)
249249

250250

251-
@pytest.mark.asyncio()
251+
@pytest.mark.asyncio
252252
async def test_retrieve(git: Git, git_testrepo: Tuple[Path, List[GitRef]]):
253253
"""Test the `retrieve` method."""
254254
root, git_refs = git_testrepo
@@ -259,7 +259,7 @@ async def test_retrieve(git: Git, git_testrepo: Tuple[Path, List[GitRef]]):
259259
assert compare_refs(ref1, ref2)
260260

261261

262-
@pytest.mark.asyncio()
262+
@pytest.mark.asyncio
263263
async def test_retrieve_with_predicate(
264264
git_with_predicate: Git, git_testrepo: Tuple[Path, List[GitRef]]
265265
):
@@ -271,7 +271,7 @@ async def test_retrieve_with_predicate(
271271
assert compare_refs(refs[1], git_refs[3])
272272

273273

274-
@pytest.mark.asyncio()
274+
@pytest.mark.asyncio
275275
async def test_closest_tag(git_testrepo: Tuple[Path, List[GitRef]]):
276276
"""Test the `closest_tag` method."""
277277
root, git_refs = git_testrepo
@@ -296,7 +296,7 @@ async def test_closest_tag(git_testrepo: Tuple[Path, List[GitRef]]):
296296
assert await closest_tag(root, git_refs[0], ["1.0", "2.0"]) is None
297297

298298

299-
@pytest.mark.asyncio()
299+
@pytest.mark.asyncio
300300
async def test_file_exists(git_testrepo: Tuple[Path, List[GitRef]]):
301301
"""Test the `file_exists` method."""
302302
root, git_refs = git_testrepo
@@ -313,7 +313,7 @@ async def test_file_exists(git_testrepo: Tuple[Path, List[GitRef]]):
313313
assert not await file_exists(root, git_refs[1], Path("dir3"))
314314

315315

316-
@pytest.mark.asyncio()
316+
@pytest.mark.asyncio
317317
async def test_file_predicate(git_testrepo: Tuple[Path, List[GitRef]]):
318318
"""Test the `file_exists` method."""
319319
root, git_refs = git_testrepo

0 commit comments

Comments
 (0)