Skip to content

Commit fe249c9

Browse files
committed
Add typing and enforce checking via tox/CI
This uses the same mypy settings as wsproto. The Sentinel values are problematic, but I've found no good solution that also has the property that type(Sentinel) is Sentinel - so this should suffice for now. Whilst I've been lazy with the tests, I've mostly avoided type ignores in the main code. This should ensure that mypyc can be used if desired.
1 parent 6578c26 commit fe249c9

21 files changed

+734
-342
lines changed

h11/__init__.py

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,57 @@
66
# semantics to check that what you're asking to write to the wire is sensible,
77
# but at least it gets you out of dealing with the wire itself.
88

9-
from ._connection import *
10-
from ._events import *
11-
from ._state import *
12-
from ._util import LocalProtocolError, ProtocolError, RemoteProtocolError
13-
from ._version import __version__
9+
from h11._connection import Connection, NEED_DATA, PAUSED
10+
from h11._events import (
11+
ConnectionClosed,
12+
Data,
13+
EndOfMessage,
14+
Event,
15+
InformationalResponse,
16+
Request,
17+
Response,
18+
)
19+
from h11._state import (
20+
CLIENT,
21+
CLOSED,
22+
DONE,
23+
ERROR,
24+
IDLE,
25+
MIGHT_SWITCH_PROTOCOL,
26+
MUST_CLOSE,
27+
SEND_BODY,
28+
SEND_RESPONSE,
29+
SERVER,
30+
SWITCHED_PROTOCOL,
31+
)
32+
from h11._util import LocalProtocolError, ProtocolError, RemoteProtocolError
33+
from h11._version import __version__
1434

1535
PRODUCT_ID = "python-h11/" + __version__
1636

1737

18-
__all__ = ["ProtocolError", "LocalProtocolError", "RemoteProtocolError"]
19-
__all__ += _events.__all__
20-
__all__ += _connection.__all__
21-
__all__ += _state.__all__
38+
__all__ = (
39+
"Connection",
40+
"NEED_DATA",
41+
"PAUSED",
42+
"ConnectionClosed",
43+
"Data",
44+
"EndOfMessage",
45+
"Event",
46+
"InformationalResponse",
47+
"Request",
48+
"Response",
49+
"CLIENT",
50+
"CLOSED",
51+
"DONE",
52+
"ERROR",
53+
"IDLE",
54+
"MUST_CLOSE",
55+
"SEND_BODY",
56+
"SEND_RESPONSE",
57+
"SERVER",
58+
"SWITCHED_PROTOCOL",
59+
"ProtocolError",
60+
"LocalProtocolError",
61+
"RemoteProtocolError",
62+
)

0 commit comments

Comments
 (0)