The `Response` instance is built by `HTTPAdapter`. When built, a property called `connection` is added to the `Response` that points back to the `HTTPAdapter` that created it. For example, this is used in the `requests` library's `HTTPDigestAuth` class to remake requests with credentials after authorization is requested by a server.
https://github.com/python/typeshed/pull/7773 changed
`requests.session.Session` methods to accept None for header values, but
didn't do quite the same for the functions in `requests.api`. I think
this was a mistake. The functions in `requests.api` just pass through
the `headers` argument without doing anything in particular to it.
Furthermore, it's useful to be able to pass None as a header value:
because `requests.utils.default_headers` sets an `Accept-Encoding`
header by default, the easiest way to send a request with no
`Accept-Encoding` header is something like `requests.get(url,
headers={"Accept-Encoding": None})`. It's annoying to have to construct
a `Session` just to pass type-checking.
It's a little confusing for the type alias to be called
`_HeadersUpdateMapping` in `requests.sessions` but `_HeadersMapping` in
`requests.api`; this is because the latter name was already used in
other type stubs (`tensorflow.keras.callbacks`), so it seemed best to
avoid breaking API.
This aligns with the definition in requests, but means that user code might
need additional assertions to ensure that `HTTPError.response` is not `None`.
Both types-requests and types-influxdb-client now depend on urllib3>=2 instead of types-urllib3. That in turn means that types-caldav, types-slumber and types-requests-oauthlib all depend indirectly on urllib3>=2, since all three stubs packages depend on types-requests.
Release: https://pypi.org/pypi/requests/2.31.0
Homepage: https://requests.readthedocs.io
Diff: https://github.com/psf/requests/compare/v2.30.0...v2.31.0
Stubsabot analysis of the diff between the two releases:
- 0 public Python files have been added.
- 0 files included in typeshed's stubs have been deleted.
- 2 files included in typeshed's stubs have been modified or renamed: `requests/__version__.py`, `requests/sessions.py`.
- Total lines of Python code added: 26.
- Total lines of Python code deleted: 4.
If you're reading about this commit from an autogenerated changelog entry, this should have no user-visible impact on how the stubs are interpreted by a type checker; it's just an internal change to how typeshed's tests work.
The final mypy_primer report for #8762 was an empty diff. Considering the number of issues we've had with our requests stubs over the last year, it feels like it makes sense to add a test case to make sure that it doesn't regress.