Skip to content

Commit 8bbc84c

Browse files
bluetechKriechi
authored andcommitted
Set mypy show_error_codes and change type-ignore to specific error codes
This makes it easier to see what is being ignored, and doesn't ignore any unrelated error that might come up in the line.
1 parent 1cd0de0 commit 8bbc84c

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

compliance/run-autobahn-tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import subprocess
1111
import sys
1212
import time
13-
from typing import Any, Dict, List, Tuple
13+
from typing import Dict, List, Tuple
1414

1515
PORT = 8642
1616

@@ -62,7 +62,7 @@
6262
}
6363

6464

65-
def say(*args: Any) -> None: # type: ignore
65+
def say(*args: object) -> None:
6666
print("run-autobahn-tests.py:", *args)
6767

6868

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ disallow_untyped_decorators = True
4141
disallow_untyped_defs = True
4242
implicit_reexport = False
4343
no_implicit_optional = True
44+
show_error_codes = True
4445
strict_equality = True
4546
strict_optional = True
4647
warn_redundant_casts = True

src/wsproto/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Request(Event):
5454

5555
host: str
5656
target: str
57-
extensions: Union[Sequence[Extension], Sequence[str]] = field( # type: ignore
57+
extensions: Union[Sequence[Extension], Sequence[str]] = field( # type: ignore[assignment]
5858
default_factory=list
5959
)
6060
extra_headers: Headers = field(default_factory=list)

src/wsproto/handshake.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,18 @@ def _initiate_connection(self, request: Request) -> bytes:
344344
)
345345

346346
if request.extensions:
347-
offers = {e.name: e.offer() for e in request.extensions} # type: ignore
347+
offers: Dict[str, Union[str, bool]] = {}
348+
for e in request.extensions:
349+
assert isinstance(e, Extension)
350+
offers[e.name] = e.offer()
348351
extensions = []
349352
for name, params in offers.items():
350-
name = name.encode("ascii")
353+
bname = name.encode("ascii")
351354
if isinstance(params, bool):
352355
if params:
353-
extensions.append(name)
356+
extensions.append(bname)
354357
else:
355-
extensions.append(b"%s; %s" % (name, params.encode("ascii")))
358+
extensions.append(b"%s; %s" % (bname, params.encode("ascii")))
356359
if extensions:
357360
headers.append((b"Sec-WebSocket-Extensions", b", ".join(extensions)))
358361

test/test_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_closure(client_sends: bool, code: CloseReason, reason: str) -> None:
6565
assert event.code is code
6666
assert event.reason == reason
6767

68-
assert remote.state is ConnectionState.CLOSED # type: ignore
68+
assert remote.state is ConnectionState.CLOSED # type: ignore[comparison-overlap]
6969
assert local.state is ConnectionState.CLOSED
7070

7171

test/test_extensions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ def test_finalize(self) -> None:
2222

2323
def test_frame_inbound_header(self) -> None:
2424
ext = wpext.Extension()
25-
result = ext.frame_inbound_header(None, None, None, None) # type: ignore
25+
result = ext.frame_inbound_header(None, None, None, None) # type: ignore[arg-type]
2626
assert result == fp.RsvBits(False, False, False)
2727

2828
def test_frame_inbound_payload_data(self) -> None:
2929
ext = wpext.Extension()
3030
data = b""
31-
assert ext.frame_inbound_payload_data(None, data) == data # type: ignore
31+
assert ext.frame_inbound_payload_data(None, data) == data # type: ignore[arg-type]
3232

3333
def test_frame_inbound_complete(self) -> None:
3434
ext = wpext.Extension()
35-
assert ext.frame_inbound_complete(None, None) is None # type: ignore
35+
assert ext.frame_inbound_complete(None, None) is None # type: ignore[arg-type]
3636

3737
def test_frame_outbound(self) -> None:
3838
ext = wpext.Extension()
3939
rsv = fp.RsvBits(True, True, True)
4040
data = b""
41-
assert ext.frame_outbound(None, None, rsv, data, None) == ( # type: ignore
41+
assert ext.frame_outbound(None, None, rsv, data, None) == ( # type: ignore[arg-type]
4242
rsv,
4343
data,
4444
)

0 commit comments

Comments
 (0)