Skip to content

Commit af91737

Browse files
committed
Replace flake8 and isort by ruff.
Configure in pyproject.toml instead of setup.cfg. Fix #1306.
1 parent 0924e9c commit af91737

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ jobs:
4444
- name: Check code formatting
4545
run: tox -e black
4646
- name: Check code style
47-
run: tox -e flake8
48-
- name: Check imports ordering
49-
run: tox -e isort
47+
run: tox -e ruff
5048
- name: Check types statically
5149
run: tox -e mypy
5250

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
.PHONY: default style test coverage maxi_cov build clean
1+
.PHONY: default style types tests coverage maxi_cov build clean
22

33
export PYTHONASYNCIODEBUG=1
44
export PYTHONPATH=src
55
export PYTHONWARNINGS=default
66

7-
default: coverage style
7+
default: style types tests
88

99
style:
10-
isort --project websockets src tests
1110
black src tests
12-
flake8 src tests
11+
ruff --fix src tests
12+
13+
types:
1314
mypy --strict src
1415

15-
test:
16+
tests:
1617
python -m unittest
1718

1819
coverage:

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,19 @@ exclude_lines = [
5858
"self.fail\\(\".*\"\\)",
5959
"@unittest.skip",
6060
]
61+
62+
[tool.ruff]
63+
select = [
64+
"E", # pycodestyle
65+
"F", # Pyflakes
66+
"W", # pycodestyle
67+
"I", # isort
68+
]
69+
ignore = [
70+
"F403",
71+
"F405",
72+
]
73+
74+
[tool.ruff.isort]
75+
combine-as-imports = true
76+
lines-after-imports = 2

setup.cfg

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

src/websockets/legacy/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ def select_subprotocol(
552552
subprotocols = set(client_subprotocols) & set(server_subprotocols)
553553
if not subprotocols:
554554
return None
555-
priority = lambda p: (
556-
client_subprotocols.index(p) + server_subprotocols.index(p)
557-
)
558-
return sorted(subprotocols, key=priority)[0]
555+
return sorted(
556+
subprotocols,
557+
key=lambda p: client_subprotocols.index(p) + server_subprotocols.index(p),
558+
)[0]
559559

560560
async def handshake(
561561
self,

tox.ini

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ envlist =
77
py311
88
coverage
99
black
10-
flake8
11-
isort
10+
ruff
1211
mypy
1312

1413
[testenv]
@@ -31,13 +30,9 @@ deps = coverage
3130
commands = black --check src tests
3231
deps = black
3332

34-
[testenv:flake8]
35-
commands = flake8 src tests
36-
deps = flake8
37-
38-
[testenv:isort]
39-
commands = isort --check-only src tests
40-
deps = isort
33+
[testenv:ruff]
34+
commands = ruff src tests
35+
deps = ruff
4136

4237
[testenv:mypy]
4338
commands = mypy --strict src

0 commit comments

Comments
 (0)