Skip to content

Commit 87442eb

Browse files
authored
Merge pull request #75 from SethMichaelLarson/patch-1
Make all sentinel values inspectable by IDEs
2 parents 9c10614 + 7bfa5b8 commit 87442eb

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

h11/_state.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,31 @@
115115
from ._util import LocalProtocolError, make_sentinel
116116

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

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)
125+
CLIENT = make_sentinel("CLIENT")
126+
SERVER = make_sentinel("SERVER")
129127

130-
__all__ += [s for s in sentinels if not s.startswith("_")]
128+
# States
129+
IDLE = make_sentinel("IDLE")
130+
SEND_RESPONSE = make_sentinel("SEND_RESPONSE")
131+
SEND_BODY = make_sentinel("SEND_BODY")
132+
DONE = make_sentinel("DONE")
133+
MUST_CLOSE = make_sentinel("MUST_CLOSE")
134+
CLOSED = make_sentinel("CLOSED")
135+
ERROR = make_sentinel("ERROR")
136+
137+
# Switch types
138+
MIGHT_SWITCH_PROTOCOL = make_sentinel("MIGHT_SWITCH_PROTOCOL")
139+
SWITCHED_PROTOCOL = make_sentinel("SWITCHED_PROTOCOL")
140+
141+
_SWITCH_UPGRADE = make_sentinel("_SWITCH_UPGRADE")
142+
_SWITCH_CONNECT = make_sentinel("_SWITCH_CONNECT")
131143

132144
EVENT_TRIGGERED_TRANSITIONS = {
133145
CLIENT: {

0 commit comments

Comments
 (0)