Backlog
We discovered a few spots which could be improved on behalf of the Niquests library, or its documentation. On the other hand, maybe we just did not read it properly, so please bear with us.
Compatibility with requests-cache
Was slightly struggling to make requests-cache work again, also because of bad code quality of grafana-wtf. With support by Ahmed, the code in compat.py does the trick. Maybe it is advisable to demonstrate that snippet at Recommended Packages and Extensions - Niquests 3.5.5 documentation.
– Request cache stopped working? · Issue #132 · panodata/grafana-wtf · GitHub
requests-mock
& custom matchers
Does not work with custom matchers of requests-mock out of the box, but would need adjustments. Maybe API compatibility or docs can be improved?
– Add support for Grafana library elements by amotl · Pull Request #168 · panodata/grafana-client · GitHub
Unclear error message
… on processing failures, when Niquests is accidentally used together with elements from Requests, like requests.adapters.HTTPAdapter
.
TypeError: expected string or bytes-like object
– Problem with grafana-client 4.0.0: `TypeError: expected string or bytes-like object` · Issue #126 · panodata/grafana-wtf · GitHub
Monkeypatching requests
Q: Provide the bootstrapping code by the library itself already?
A: It would not be wise outside of a development environment.
Details
So that code like this:
from sys import modules
import niquests
import urllib3
# Amalgamate the module namespace to make all modules aiming
# to use `requests`, in fact use `niquests` instead.
modules["requests"] = niquests
modules["requests.adapters"] = niquests.adapters
modules["requests.sessions"] = niquests.sessions
modules["requests.exceptions"] = niquests.exceptions
modules["requests.packages.urllib3"] = urllib3
can effectively be compressed into that:
from niquests import monkey
monkey.patch_all()
– SQLite cache: Use `requests_cache.CachedSession` for better concurrency by amotl · Pull Request #130 · panodata/grafana-wtf · GitHub
Thoughts
In cases where it might be unclear, we will be happy to provide more details, for example reproducers how we have been able to run into corresponding situations.
Alternatively to this enumeration, we may also file dedicated issues at the issue tracker of the upstream project GitHub - jawah/niquests: Requests but with HTTP/3, HTTP/2, Multiplexed Connections, System CAs, Certificate Revocation, DNS over HTTPS / TLS / QUIC or UDP, Async, DNSSEC, and (much) pain removed!. However, this needs more effort than just taking notes about them, so here we are.