Skip to content

Commit 01ef1c8

Browse files
Clarify wording of interceptor documentation
1 parent bd8caca commit 01ef1c8

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

python-packages/smithy-python/smithy_python/interfaces/interceptor.py

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ def response(self) -> Response | Exception:
5050
"""
5151
return self._response
5252

53+
# Note that TransportRequest (and TransportResponse below) aren't resolved types,
54+
# but rather TypeVars. This is very important, because in the actual Interceptor
55+
# interface class these are sometimes typed as None rather than, say, HttpRequest.
56+
# That lets us use the type system to tell people when something will be set and
57+
# when it will not be set without leaking nullability into the cases where the
58+
# property will ALWAYS be set.
5359
@property
5460
def transport_request(self) -> TransportRequest:
5561
"""Retrieve the transmittable request for the operation being invoked.
@@ -146,15 +152,15 @@ def modify_before_serialization(
146152
self, context: InterceptorContext[Request, None, None, None]
147153
) -> Request:
148154
"""
149-
A hook called before the request is marshalled into a transport message.
155+
A hook called before the request is serialized into a transport request.
150156
This method has the ability to modify and return a new request of the
151157
same type.
152158
153159
This will ALWAYS be called once per execution, except when a failure occurs
154160
earlier in the request pipeline.
155161
156162
The `request` of the context will always be available. This `request` may have
157-
been modified by earlier `modify_before_serializtion` hooks, and may be
163+
been modified by earlier `modify_before_serialization` hooks, and may be
158164
modified further by later hooks. Other static properites will be None.
159165
160166
If exceptions are thrown by this hook, execution will jump to
@@ -169,7 +175,7 @@ def read_before_serialization(
169175
self, context: InterceptorContext[Request, None, None, None]
170176
) -> None:
171177
"""
172-
A hook called before the input message is marshalled into a transport message.
178+
A hook called before the input message is serialized into a transport request.
173179
174180
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
175181
or `transport_response` in this hook.
@@ -191,15 +197,15 @@ def read_after_serialization(
191197
self, context: InterceptorContext[Request, None, TransportRequest, None]
192198
) -> None:
193199
"""
194-
A hook called after the input message is marshalled into a transport message.
200+
A hook called after the input message is serialized into a transport request.
195201
196202
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
197203
or `transport_response` in this hook.
198204
199205
This will always be called once per execution, except when a failure occurs
200-
earlier in the request pipeline. The duration between invocation of this hook
201-
and `read_before_serialization` is very close to the amount of time spent
202-
marshalling the request.
206+
earlier in the request pipeline. The duration between
207+
`read_before_serialization` and the invocation of this hook is very close to
208+
the amount of time spent serializing the request.
203209
204210
The `request` and `transport_request` of the context will always be available.
205211
Other static properties will be None.
@@ -231,8 +237,8 @@ def read_before_attempt(
231237
self, context: InterceptorContext[Request, None, TransportRequest, None]
232238
) -> None:
233239
"""
234-
A hook called before each attempt at sending the transmission request message
235-
to the service.
240+
A hook called before each attempt at sending the transport request to the
241+
service.
236242
237243
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
238244
or `transport_response` in this hook.
@@ -258,9 +264,8 @@ def modify_before_signing(
258264
self, context: InterceptorContext[Request, None, TransportRequest, None]
259265
) -> TransportRequest:
260266
"""
261-
A hook called before the transport request message is signed. This method has
262-
the ability to modify and return a new transport request message of the same
263-
type.
267+
A hook called before the transport request is signed. This method has the
268+
ability to modify and return a new transport request of the same type.
264269
265270
This will always be called once per attempt, except when a failure occurs
266271
earlier in the request pipeline. This method will be called multiple times in
@@ -284,7 +289,7 @@ def read_before_signing(
284289
self, context: InterceptorContext[Request, None, TransportRequest, None]
285290
) -> None:
286291
"""
287-
A hook called before the transport request message is signed.
292+
A hook called before the transport request is signed.
288293
289294
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
290295
or `transport_response` in this hook.
@@ -309,15 +314,15 @@ def read_after_signing(
309314
self, context: InterceptorContext[Request, None, TransportRequest, None]
310315
) -> None:
311316
"""
312-
A hook called after the transport request message is signed.
317+
A hook called after the transport request is signed.
313318
314319
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
315320
or `transport_response` in this hook.
316321
317322
This will always be called once per attempt, except when a failure occurs
318323
earlier in the request pipeline. This method may be called multiple times in
319-
the event of retries. The duration between invocation of this hook and
320-
`read_before_signing` is very close to the amount of time spent signing the
324+
the event of retries. The duration between `read_before_signing` and the
325+
invocation of this hook is very close to the amount of time spent signing the
321326
request.
322327
323328
The `request` and `transport_request` of the context will always be available.
@@ -334,8 +339,8 @@ def modify_before_transmit(
334339
self, context: InterceptorContext[Request, None, TransportRequest, None]
335340
) -> TransportRequest:
336341
"""
337-
A hook called before the transport request message is sent to the service. This
338-
method has the ability to modify and return a new transport request message of
342+
A hook called before the transport request is sent to the service. This
343+
method has the ability to modify and return a new transport request of
339344
the same type.
340345
341346
This will always be called once per attempt, except when a failure occurs
@@ -360,14 +365,14 @@ def read_before_transmit(
360365
self, context: InterceptorContext[Request, None, TransportRequest, None]
361366
) -> None:
362367
"""
363-
A hook called before the transport request message is sent to the service.
368+
A hook called before the transport request is sent to the service.
364369
365370
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
366371
or `transport_response` in this hook.
367372
368373
This will always be called once per attempt, except when a failure occurs
369374
earlier in the request pipeline. This method may be called multiple times in
370-
the event of retries.The duration between invocation of this hook and
375+
the event of retries. The duration between invocation of this hook and
371376
`read_after_transmit` is very close to the amount of time spent communicating
372377
with the service. Depending on the protocol, the duration may not include the
373378
time spent reading the response data.
@@ -387,16 +392,16 @@ def read_after_transmit(
387392
context: InterceptorContext[Request, None, TransportRequest, TransportResponse],
388393
) -> None:
389394
"""
390-
A hook called after the transport request message is sent to the service and a
395+
A hook called after the transport request is sent to the service and a
391396
transport response is received.
392397
393398
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
394399
or `transport_response` in this hook.
395400
396401
This will always be called once per attempt, except when a failure occurs
397402
earlier in the request pipeline. This method may be called multiple times in
398-
the event of retries. The duration between invocation of this hook and
399-
`read_before_transmit` is very close to the amount of time spent communicating
403+
the event of retries. The duration between `read_before_transmit` and the
404+
invocation of this hook is very close to the amount of time spent communicating
400405
with the service. Depending on the protocol, the duration may not include the
401406
time spent reading the response data.
402407
@@ -415,7 +420,7 @@ def modify_before_deserialization(
415420
context: InterceptorContext[Request, None, TransportRequest, TransportResponse],
416421
) -> TransportResponse:
417422
"""
418-
A hook called before the transport response is unmarshalled. This method has
423+
A hook called before the transport response is deserialized. This method has
419424
the ability to modify and return a new transport response of the same type.
420425
421426
This will always be called once per attempt, except when a failure occurs
@@ -444,7 +449,7 @@ def read_before_deserialization(
444449
context: InterceptorContext[Request, None, TransportRequest, TransportResponse],
445450
) -> None:
446451
"""
447-
A hook called before the transport response is unmarshalled.
452+
A hook called before the transport response is deserialized.
448453
449454
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
450455
or `transport_response` in this hook.
@@ -453,7 +458,7 @@ def read_before_deserialization(
453458
earlier in the request pipeline. This method may be called multiple times in
454459
the event of retries. The duration between invocation of this hook and
455460
`read_after_deserialization` is very close to the amount of time spent
456-
unmarshalling the service response. Depending on the protocol and operation,
461+
deserializing the service response. Depending on the protocol and operation,
457462
the duration may include the time spent downloading the response data.
458463
459464
The `request`, `transport_request`, and `transport_response` of the context
@@ -473,16 +478,16 @@ def read_after_deserialization(
473478
],
474479
) -> None:
475480
"""
476-
A hook called after the transport response is unmarshalled.
481+
A hook called after the transport response is deserialized.
477482
478483
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
479484
or `transport_response` in this hook.
480485
481486
This will always be called once per attempt, except when a failure occurs
482487
earlier in the request pipeline. This method may be called multiple times in
483-
the event of retries. The duration between invocation of this hook and
484-
`read_before_deserialization` is very close to the amount of time spent
485-
unmarshalling the service response. Depending on the protocol and operation,
488+
the event of retries. The duration between `read_before_deserialization`
489+
and the invocation of this hook is very close to the amount of time spent
490+
deserializing the service response. Depending on the protocol and operation,
486491
the duration may include the time spent downloading the response data.
487492
488493
The `request`, `response`, `transport_request`, and `transport_response` of the
@@ -592,9 +597,9 @@ def read_after_execution(
592597
Implementations MUST NOT modify the `request`, `response`, `transport_request`,
593598
or `transport_response` in this hook.
594599
595-
This will always be called once per execution. The duration between invocation
596-
of this hook and `read_before_execution` is very close to the full duration of
597-
the execution.
600+
This will always be called once per execution. The duration between
601+
`read_before_execution` and the invocation of this hook is very close to the
602+
full duration of the execution.
598603
599604
The `request` and `response` of the context will always be available. The
600605
`transport_request` and `transport_response` will be available if the execution

0 commit comments

Comments
 (0)