Skip to content

Commit 1f89db7

Browse files
committed
Switch from black to ruff for code formatting.
It's faster and achieves pretty much the same result.
1 parent f842a13 commit 1f89db7

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

.github/workflows/tests.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ jobs:
4141
python-version: "3.x"
4242
- name: Install tox
4343
run: pip install tox
44-
- name: Check code formatting
45-
run: tox -e black
46-
- name: Check code style
44+
- name: Check code formatting & style
4745
run: tox -e ruff
4846
- name: Check types statically
4947
run: tox -e mypy

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
python setup.py build_ext --inplace
99

1010
style:
11-
black src tests
11+
ruff format src tests
1212
ruff check --fix src tests
1313

1414
types:

src/websockets/asyncio/client.py

-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def __init__(
297297
# Other keyword arguments are passed to loop.create_connection
298298
**kwargs: Any,
299299
) -> None:
300-
301300
wsuri = parse_uri(uri)
302301

303302
if wsuri.secure:

src/websockets/asyncio/server.py

-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ def __init__(
722722
# Other keyword arguments are passed to loop.create_server
723723
**kwargs: Any,
724724
) -> None:
725-
726725
if subprotocols is not None:
727726
validate_subprotocols(subprotocols)
728727

src/websockets/legacy/server.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ class WebSocketServerProtocol(WebSocketCommonProtocol):
100100

101101
def __init__(
102102
self,
103+
# The version that accepts the path in the second argument is deprecated.
103104
ws_handler: (
104105
Callable[[WebSocketServerProtocol], Awaitable[Any]]
105-
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]] # deprecated
106+
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]]
106107
),
107108
ws_server: WebSocketServer,
108109
*,
@@ -983,9 +984,10 @@ class Serve:
983984

984985
def __init__(
985986
self,
987+
# The version that accepts the path in the second argument is deprecated.
986988
ws_handler: (
987989
Callable[[WebSocketServerProtocol], Awaitable[Any]]
988-
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]] # deprecated
990+
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]]
989991
),
990992
host: str | Sequence[str] | None = None,
991993
port: int | None = None,
@@ -1140,9 +1142,10 @@ async def __await_impl__(self) -> WebSocketServer:
11401142

11411143

11421144
def unix_serve(
1145+
# The version that accepts the path in the second argument is deprecated.
11431146
ws_handler: (
11441147
Callable[[WebSocketServerProtocol], Awaitable[Any]]
1145-
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]] # deprecated
1148+
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]]
11461149
),
11471150
path: str | None = None,
11481151
**kwargs: Any,
@@ -1169,7 +1172,7 @@ def remove_path_argument(
11691172
ws_handler: (
11701173
Callable[[WebSocketServerProtocol], Awaitable[Any]]
11711174
| Callable[[WebSocketServerProtocol, str], Awaitable[Any]]
1172-
)
1175+
),
11731176
) -> Callable[[WebSocketServerProtocol], Awaitable[Any]]:
11741177
try:
11751178
inspect.signature(ws_handler).bind(None)

tests/legacy/test_client_server.py

-1
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,6 @@ def test_connection_error_during_closing_handshake(self, close):
12931293
class ClientServerTests(
12941294
CommonClientServerTests, ClientServerTestsMixin, AsyncioTestCase
12951295
):
1296-
12971296
def test_redirect_secure(self):
12981297
with temp_test_redirecting_server(self):
12991298
# websockets doesn't support serving non-TLS and TLS connections

tox.ini

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ env_list =
77
py312
88
py313
99
coverage
10-
black
1110
ruff
1211
mypy
1312

1413
[testenv]
15-
commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m unittest {posargs}
14+
commands =
15+
python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m unittest {posargs}
1616
pass_env = WEBSOCKETS_*
1717

1818
[testenv:coverage]
@@ -27,14 +27,13 @@ commands =
2727
python -m coverage report --show-missing --fail-under=100
2828
deps = coverage
2929

30-
[testenv:black]
31-
commands = black --check src tests
32-
deps = black
33-
3430
[testenv:ruff]
35-
commands = ruff check src tests
31+
commands =
32+
ruff format --check src tests
33+
ruff check src tests
3634
deps = ruff
3735

3836
[testenv:mypy]
39-
commands = mypy --strict src
37+
commands =
38+
mypy --strict src
4039
deps = mypy

0 commit comments

Comments
 (0)