Skip to content

Commit a7bdffc

Browse files
carsonippgjones
authored andcommitted
Fix type hints
1 parent 04cc0f7 commit a7bdffc

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

h11/_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _get_io_object(
323323
else:
324324
# General case: the io_dict just has the appropriate reader/writer
325325
# for this state
326-
return io_dict.get((role, state)) # type: ignore
326+
return io_dict.get((role, state)) # type: ignore[return-value]
327327

328328
# This must be called after any action that might have caused
329329
# self._cstate.states to change.

h11/_readers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def expect_nothing(buf: ReceiveBuffer) -> None:
225225

226226

227227
ReadersType = Dict[
228-
Union[Sentinel, Tuple[Sentinel, Sentinel]],
228+
Union[Type[Sentinel], Tuple[Type[Sentinel], Type[Sentinel]]],
229229
Union[Callable[..., Any], Dict[str, Callable[..., Any]]],
230230
]
231231

h11/_state.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,13 @@ class _SWITCH_CONNECT(Sentinel, metaclass=Sentinel):
226226
},
227227
}
228228

229+
StateTransitionType = Dict[
230+
Tuple[Type[Sentinel], Type[Sentinel]], Dict[Type[Sentinel], Type[Sentinel]]
231+
]
232+
229233
# NB: there are also some special-case state-triggered transitions hard-coded
230234
# into _fire_state_triggered_transitions below.
231-
STATE_TRIGGERED_TRANSITIONS = {
235+
STATE_TRIGGERED_TRANSITIONS: StateTransitionType = {
232236
# (Client state, Server state) -> new states
233237
# Protocol negotiation
234238
(MIGHT_SWITCH_PROTOCOL, SWITCHED_PROTOCOL): {CLIENT: SWITCHED_PROTOCOL},
@@ -345,7 +349,7 @@ def _fire_state_triggered_transitions(self) -> None:
345349
# Tabular state-triggered transitions
346350
joint_state = (self.states[CLIENT], self.states[SERVER])
347351
changes = STATE_TRIGGERED_TRANSITIONS.get(joint_state, {})
348-
self.states.update(changes) # type: ignore
352+
self.states.update(changes)
349353

350354
if self.states == start_states:
351355
# Fixed point reached

h11/_writers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def send_eom(self, headers: Headers, write: Writer) -> None:
125125

126126

127127
WritersType = Dict[
128-
Union[Tuple[Sentinel, Sentinel], Sentinel],
128+
Union[Tuple[Type[Sentinel], Type[Sentinel]], Type[Sentinel]],
129129
Union[
130130
Dict[str, Type[BodyWriter]],
131131
Callable[[Union[InformationalResponse, Response], Writer], None],

0 commit comments

Comments
 (0)