Skip to content

Commit ff50ac7

Browse files
Migrate flake8 and black to ruff
1 parent c5a43c9 commit ff50ac7

File tree

6 files changed

+24
-26
lines changed

6 files changed

+24
-26
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ jobs:
4343
- name: Install dependencies
4444
run: uv sync
4545
- name: Lint
46-
run: uv run flake8
46+
run: uv run ruff check
47+
- name: Format
48+
run: uv run ruff format --check
4749
- name: Test
4850
run: uv run pytest -v --cov=patchdiff --cov-report=term-missing
4951

@@ -63,7 +65,7 @@ jobs:
6365
- name: Build wheel
6466
run: uv build
6567
- name: Twine check
66-
run: uv run twine check dist/*
68+
run: uvx twine check dist/*
6769
- name: Upload wheel artifact
6870
uses: actions/upload-artifact@v4
6971
with:

patchdiff/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ def pad(state, op, target=None):
7171
"path": ptr.append(idx_token),
7272
"value": op["value"],
7373
}
74-
return [ops + [full_op], padding + 1]
74+
return [[*ops, full_op], padding + 1]
7575
elif op["op"] == "remove":
7676
full_op = {
7777
"op": "remove",
7878
"path": ptr.append(op["idx"] + padding),
7979
}
80-
return [ops + [full_op], padding - 1]
80+
return [[*ops, full_op], padding - 1]
8181
else:
8282
replace_ptr = ptr.append(op["idx"] + padding)
8383
replace_ops, _ = diff(op["original"], op["value"], replace_ptr)

patchdiff/pointer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from .types import Diffable
55

6-
76
tilde0_re = re.compile("~0")
87
tilde1_re = re.compile("~1")
98
tilde_re = re.compile("~")
@@ -19,7 +18,7 @@ def escape(token: str) -> str:
1918

2019

2120
class Pointer:
22-
def __init__(self, tokens: List[Hashable] = None) -> None:
21+
def __init__(self, tokens: List[Hashable] | None = None) -> None:
2322
if tokens is None:
2423
tokens = []
2524
self.tokens = tuple(tokens)
@@ -33,7 +32,7 @@ def __str__(self) -> str:
3332
return "/" + "/".join(escape(str(t)) for t in self.tokens)
3433

3534
def __repr__(self) -> str:
36-
return f"Pointer({repr(list(self.tokens))})"
35+
return f"Pointer({list(self.tokens)!r})"
3736

3837
def __hash__(self) -> int:
3938
return hash(self.tokens)
@@ -62,4 +61,4 @@ def evaluate(self, obj: Diffable) -> Tuple[Diffable, Hashable, Any]:
6261

6362
def append(self, token: Hashable) -> "Pointer":
6463
"""append, creating new Pointer"""
65-
return Pointer(self.tokens + (token,))
64+
return Pointer((*self.tokens, token))

pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ Homepage = "https://github.com/fork-tongue/patchdiff"
1414

1515
[dependency-groups]
1616
dev = [
17-
"flake8",
18-
"black",
19-
"flake8-black",
20-
"flake8-import-order",
21-
"flake8-print",
17+
"ruff",
2218
"pytest",
2319
"pytest-cov",
2420
"pytest-watch",
25-
"twine",
2621
]
2722

23+
[tool.ruff.lint]
24+
extend-select = [
25+
"F", # Pyflakes (default)
26+
"I", # isort imports
27+
"N", # pep8-naming
28+
"T10", # flake8-debugger
29+
"T20", # flake8-print
30+
"RUF", # ruff
31+
]
32+
33+
[tool.ruff.lint.per-file-ignores]
34+
"patchdiff/__init__.py" = ["F401"]
35+
2836
[build-system]
2937
requires = ["hatchling"]
3038
build-backend = "hatchling.build"

setup.cfg

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

tests/test_proxy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Tests that check that patchdiff apply and diff work
33
on proxied objects.
44
"""
5+
56
from collections import UserDict, UserList
67
from collections.abc import Set
78

0 commit comments

Comments
 (0)