Open
Description
Describe the bug
We can pass the trace_request_ctx arg to varios ClientSession
verbs (get, put, request, etc.) . However, the typing annotation for this request context is trace_request_ctx: Union[Mapping[str, Any], None]
, which is incompatible with passing an instance of a custom class.
For example, I would like to be able to pass a request context of an arbitrary class instead of a Mapping
, perhaps something like this example :
@dataclass
class MyRequestCrumbs:
num_attempts: int
unique_id: UUID
...
crumbs = MyRequestCrumbs(num_attempts=0, unique_id=uuid.uuid1())
await session.request(..., trace_request_ctx=crumbs)
To Reproduce
See description
Expected behavior
I expected the typing annotation of trace_request_ctx
to support request context instances of any class, including user-defined classes
Logs/tracebacks
N/A
Python Version
$ python --version
Python 3.10.14
aiohttp Version
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.11.12
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache-2.0
Location: /Users/vkruglik/git/bcps-engine-project/venv/lib/python3.10/site-packages
Requires: aiohappyeyeballs, aiosignal, async-timeout, attrs, frozenlist, multidict, propcache, yarl
Required-by:
multidict Version
$ python -m pip show multidict
N/A
propcache Version
$ python -m pip show propcache
N/A
yarl Version
$ python -m pip show yarl
N/A
OS
N/A
Related component
Client
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct