Skip to content

Commit d0bf87a

Browse files
committed
chore: use ruff formatter
1 parent 8dfdc63 commit d0bf87a

File tree

13 files changed

+40
-49
lines changed

13 files changed

+40
-49
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
matrix:
4141
env:
4242
- build
43-
- format
4443
- generate-integration-files
4544
- lint
4645
- type

.isort.cfg

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

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"charliermarsh.ruff",
4+
"esbenp.prettier-vscode",
5+
"ms-python.python"
6+
]
7+
}

.vscode/settings.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
".eggs": true,
66
"**/*.egg-info": true,
77
".coverage": true,
8+
".mypy_cache": true,
89
".pytest_cache": true,
10+
".ruff_cache": true,
911
".tox": true
1012
},
1113
"editor.detectIndentation": false,
@@ -23,17 +25,16 @@
2325
"editor.wordWrapColumn": 88
2426
},
2527
"[python]": {
28+
"editor.defaultFormatter": "charliermarsh.ruff",
2629
"editor.codeActionsOnSave": {
27-
"source.organizeImports": true
30+
"source.organizeImports": "explicit"
2831
}
2932
},
3033
"[yaml]": {
3134
"editor.defaultFormatter": "esbenp.prettier-vscode",
3235
"editor.tabSize": 2
3336
},
3437
"python.envFile": "${workspaceFolder}/.vscode/env",
35-
"python.formatting.provider": "black",
3638
"python.linting.pylintEnabled": true,
37-
"python.testing.pytestEnabled": true,
38-
"python.sortImports.args": ["-sp .isort.cfg"]
39+
"python.testing.pytestEnabled": true
3940
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ adheres to [Semantic Versioning](https://semver.org/).
2020
- Update GitHub actions dependencies
2121
- Add tests for PyPy 3.10 and 3.11
2222
- Improve tox & CI pipelines
23+
- Use ruff as formatter
2324

2425
## [0.5.0] - 2023-02-27
2526

dev-requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
# build
55
build==1.3.0
66

7-
# format
8-
black==23.1.0
9-
isort==5.12.0
10-
117
# lint
128
pylint==2.16.2
9+
ruff==0.13.1
1310

1411
# typing
1512
mypy==1.0.1

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# ruff
3+
#
4+
5+
[tool.ruff]
6+
src = ["src"]
7+
target-version = "py39"

src/xz/open.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def xz_open(
7979
encoding: Optional[str] = None,
8080
errors: Optional[str] = None,
8181
newline: Optional[str] = None,
82-
) -> XZFile:
83-
... # pragma: no cover
82+
) -> XZFile: ... # pragma: no cover
8483

8584

8685
@overload
@@ -97,8 +96,7 @@ def xz_open(
9796
encoding: Optional[str] = None,
9897
errors: Optional[str] = None,
9998
newline: Optional[str] = None,
100-
) -> _XZFileText:
101-
... # pragma: no cover
99+
) -> _XZFileText: ... # pragma: no cover
102100

103101

104102
@overload
@@ -115,8 +113,7 @@ def xz_open(
115113
encoding: Optional[str] = None,
116114
errors: Optional[str] = None,
117115
newline: Optional[str] = None,
118-
) -> Union[XZFile, _XZFileText]:
119-
... # pragma: no cover
116+
) -> Union[XZFile, _XZFileText]: ... # pragma: no cover
120117

121118

122119
def xz_open(

src/xz/typing.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424

2525

2626
class _BlockReadStrategyType(Protocol):
27-
def on_create(self, block: "XZBlock") -> None:
28-
... # pragma: no cover
27+
def on_create(self, block: "XZBlock") -> None: ... # pragma: no cover
2928

30-
def on_delete(self, block: "XZBlock") -> None:
31-
... # pragma: no cover
29+
def on_delete(self, block: "XZBlock") -> None: ... # pragma: no cover
3230

33-
def on_read(self, block: "XZBlock") -> None:
34-
... # pragma: no cover
31+
def on_read(self, block: "XZBlock") -> None: ... # pragma: no cover

tests/integration/test_ram_usage.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def test_read_linear(
6767
while xz_file.read(DEFAULT_BUFFER_SIZE):
6868
assert (
6969
# should not use much more memory, take 2 as error margin
70-
ram_usage()
71-
< one_block_memory * 2
70+
ram_usage() < one_block_memory * 2
7271
), f"Consumes too much RAM (at {100 * xz_file.tell() / len(xz_file):.0f}%)"
7372

7473

@@ -89,9 +88,10 @@ def test_partial_read_each_block(
8988
else:
9089
assert (
9190
# default strategy is max 8 blocks, take 10 as error margin
92-
ram_usage()
93-
< one_block_memory * 10
94-
), f"Consumes too much RAM (at {100 * xz_file.tell() / len(xz_file):.0f}%)"
91+
ram_usage() < one_block_memory * 10
92+
), (
93+
f"Consumes too much RAM (at {100 * xz_file.tell() / len(xz_file):.0f}%)"
94+
)
9595

9696

9797
def test_write(
@@ -115,6 +115,5 @@ def test_write(
115115
else:
116116
assert (
117117
# should not use much more memory, take 2 as error margin
118-
ram_usage()
119-
< one_block_memory * 2
118+
ram_usage() < one_block_memory * 2
120119
), f"Consumes too much RAM (at {i / nb_blocks:.0f}%)"

0 commit comments

Comments
 (0)