Skip to content

Commit

Permalink
Add typing and enforce checking via tox/CI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pgjones committed Aug 28, 2021
1 parent 5d958b5 commit 60c3e7a
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 333 deletions.
59 changes: 50 additions & 9 deletions h11/__init__.py
Expand Up @@ -6,16 +6,57 @@
# semantics to check that what you're asking to write to the wire is sensible,
# but at least it gets you out of dealing with the wire itself.

from ._connection import *
from ._events import *
from ._state import *
from ._util import LocalProtocolError, ProtocolError, RemoteProtocolError
from ._version import __version__
from h11._connection import Connection, NEED_DATA, PAUSED
from h11._events import (
ConnectionClosed,
Data,
EndOfMessage,
Event,
InformationalResponse,
Request,
Response,
)
from h11._state import (
CLIENT,
CLOSED,
DONE,
ERROR,
IDLE,
MIGHT_SWITCH_PROTOCOL,
MUST_CLOSE,
SEND_BODY,
SEND_RESPONSE,
SERVER,
SWITCHED_PROTOCOL,
)
from h11._util import LocalProtocolError, ProtocolError, RemoteProtocolError
from h11._version import __version__

PRODUCT_ID = "python-h11/" + __version__


__all__ = ["ProtocolError", "LocalProtocolError", "RemoteProtocolError"]
__all__ += _events.__all__
__all__ += _connection.__all__
__all__ += _state.__all__
__all__ = (
"Connection",
"NEED_DATA",
"PAUSED",
"ConnectionClosed",
"Data",
"EndOfMessage",
"Event",
"InformationalResponse",
"Request",
"Response",
"CLIENT",
"CLOSED",
"DONE",
"ERROR",
"IDLE",
"MUST_CLOSE",
"SEND_BODY",
"SEND_RESPONSE",
"SERVER",
"SWITCHED_PROTOCOL",
"ProtocolError",
"LocalProtocolError",
"RemoteProtocolError",
)

0 comments on commit 60c3e7a

Please sign in to comment.