Skip to content

Commit 4b44033

Browse files
authored
Make all sentinel values inspectable by IDEs
1 parent 9c10614 commit 4b44033

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

h11/_state.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,29 @@
114114
from ._events import *
115115
from ._util import LocalProtocolError, make_sentinel
116116

117-
# Everything in __all__ gets re-exported as part of the h11 public API.
118-
__all__ = []
117+
__all__ = [
118+
"CLIENT", "SERVER", "IDLE", "SEND_RESPONSE",
119+
"SEND_BODY_DONE", "MUST_CLOSE", "CLOSED",
120+
"MIGHT_SWITCH_PROTOCOL", "SWITCHED_PROTOCOL",
121+
"ERROR"
122+
]
119123

120-
# Be careful of trailing whitespace here:
121-
sentinels = ("CLIENT SERVER "
122-
# States
123-
"IDLE SEND_RESPONSE SEND_BODY DONE MUST_CLOSE CLOSED "
124-
"MIGHT_SWITCH_PROTOCOL SWITCHED_PROTOCOL ERROR "
125-
# Switch types
126-
"_SWITCH_UPGRADE _SWITCH_CONNECT").split()
127-
for token in sentinels:
128-
globals()[token] = make_sentinel(token)
124+
CLIENT = make_sentinel("CLIENT")
125+
SERVER = make_sentinel("CLIENT")
129126

130-
__all__ += [s for s in sentinels if not s.startswith("_")]
127+
# States
128+
IDLE = make_sentinel("IDLE")
129+
SEND_RESPONSE = make_sentinel("SEND_RESPONSE")
130+
SEND_BODY_DONE = make_sentinel("SEND_BODY_DONE")
131+
MUST_CLOSE = make_sentinel("MUST_CLOSE")
132+
CLOSED = make_sentinel("CLOSED")
133+
134+
# Switch types
135+
MIGHT_SWITCH_PROTOCOL = make_sentinel("CLIENT")
136+
SWITCHED_PROTOCOL = make_sentinel("SWITCHED_PROTOCOL")
137+
138+
_SWITCH_UPGRADE = make_sentinel("_SWITCH_UPGRADE")
139+
_SWITCH_CONNECT = make_sentinel("_SWITCH_CONNECT")
131140

132141
EVENT_TRIGGERED_TRANSITIONS = {
133142
CLIENT: {

0 commit comments

Comments
 (0)