Skip to content

Commit 1f87afc

Browse files
committed
linting: update black and mypy with strict checking
1 parent e0a212c commit 1f87afc

File tree

6 files changed

+16
-32
lines changed

6 files changed

+16
-32
lines changed

example/synchronous_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ def wsproto_demo(host: str, port: int) -> None:
8888

8989

9090
def net_send(out_data: bytes, conn: socket.socket) -> None:
91-
""" Write pending data from websocket to network. """
91+
"""Write pending data from websocket to network."""
9292
print("Sending {} bytes".format(len(out_data)))
9393
conn.send(out_data)
9494

9595

9696
def net_recv(ws: WSConnection, conn: socket.socket) -> None:
97-
""" Read pending data from network into websocket. """
97+
"""Read pending data from network into websocket."""
9898
in_data = conn.recv(RECEIVE_BYTES)
9999
if not in_data:
100100
# A receive of zero bytes indicates the TCP socket has been closed. We

setup.cfg

+4-20
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,9 @@ no_lines_before=LOCALFOLDER
3333
order_by_type=False
3434

3535
[mypy]
36-
check_untyped_defs = True
37-
disallow_any_decorated = True
38-
disallow_any_explicit = True
39-
# disallow_any_expr = True
40-
disallow_any_generics = True
41-
# disallow_any_unimported = True
42-
disallow_incomplete_defs = True
43-
disallow_subclassing_any = True
44-
disallow_untyped_calls = True
45-
disallow_untyped_decorators = True
46-
disallow_untyped_defs = True
47-
implicit_reexport = False
48-
no_implicit_optional = True
49-
show_error_codes = True
50-
strict_equality = True
51-
strict_optional = True
52-
warn_redundant_casts = True
53-
# warn_return_any = True
54-
warn_unused_configs = True
55-
warn_unused_ignores = True
36+
strict = true
37+
warn_unused_configs = true
38+
show_error_codes = true
39+
5640
[mypy-h11.*]
5741
ignore_missing_imports = True

src/wsproto/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ConnectionState(Enum):
4343

4444

4545
class ConnectionType(Enum):
46-
""" An enumeration of connection types. """
46+
"""An enumeration of connection types."""
4747

4848
#: This connection will act as client and talk to a remote server
4949
CLIENT = 1

src/wsproto/events.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class CloseConnection(Event):
182182
reason: Optional[str] = None
183183

184184
def response(self) -> "CloseConnection":
185-
""" Generate an RFC-compliant close frame to send back to the peer. """
185+
"""Generate an RFC-compliant close frame to send back to the peer."""
186186
return CloseConnection(code=self.code, reason=self.reason)
187187

188188

@@ -276,7 +276,7 @@ class Ping(Event):
276276
payload: bytes = b""
277277

278278
def response(self) -> "Pong":
279-
""" Generate an RFC-compliant :class:`Pong` response to this ping. """
279+
"""Generate an RFC-compliant :class:`Pong` response to this ping."""
280280
return Pong(payload=self.payload)
281281

282282

src/wsproto/handshake.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def _accept(self, event: AcceptConnection) -> bytes:
286286
event.extensions,
287287
)
288288
self._state = ConnectionState.OPEN
289-
return self._h11_connection.send(response)
289+
return self._h11_connection.send(response) # type: ignore[no-any-return]
290290

291291
def _reject(self, event: RejectConnection) -> bytes:
292292
if self.state != ConnectionState.CONNECTING:
@@ -303,7 +303,7 @@ def _reject(self, event: RejectConnection) -> bytes:
303303
if not event.has_body:
304304
data += self._h11_connection.send(h11.EndOfMessage())
305305
self._state = ConnectionState.CLOSED
306-
return data
306+
return data # type: ignore[no-any-return]
307307

308308
def _send_reject_data(self, event: RejectData) -> bytes:
309309
if self.state != ConnectionState.REJECTING:
@@ -315,7 +315,7 @@ def _send_reject_data(self, event: RejectData) -> bytes:
315315
if event.body_finished:
316316
data += self._h11_connection.send(h11.EndOfMessage())
317317
self._state = ConnectionState.CLOSED
318-
return data
318+
return data # type: ignore[no-any-return]
319319

320320
# Client mode methods
321321

@@ -360,7 +360,7 @@ def _initiate_connection(self, request: Request) -> bytes:
360360
target=request.target.encode("ascii"),
361361
headers=headers + request.extra_headers,
362362
)
363-
return self._h11_connection.send(upgrade)
363+
return self._h11_connection.send(upgrade) # type: ignore[no-any-return]
364364

365365
def _establish_client_connection(
366366
self, event: h11.InformationalResponse

tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ commands = pytest {posargs}
2626
[testenv:lint]
2727
deps =
2828
flake8>=3.9.1,<4
29-
black==20.8b1
29+
black==21.5b2
3030
isort==5.6.4
31-
mypy==0.790
32-
pytest==6.1.2
31+
mypy==0.902
32+
{[testenv]deps}
3333
commands =
3434
flake8 src/ test/
3535
black --check --diff src/ test/ example/ compliance/ bench/

0 commit comments

Comments
 (0)