Re-add support for `X-Request-ID #199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Per our internal discussion on the usefulness of
X-Request-IDfor traceability. The generator function is configurable via therequest_id_fnAPI constructor argument, defaulting to a random UUID v4 per request when unspecified.A note about optionally providing
request_id_fnas a constructor parameter: I considered adding arequest_idparameter to each API function similar to our TypeScript SDK, but decided against it due to significant argument pollution for all methods, and that it has no practical use for most users*. If ourselves or a user ever needs to customize this, that can be done ergonomically by usingTodoistApi(orTodoistAsyncApi) as a context manager or passing a context-awarerequest_id_fnfunction.*TypeScript SDK claims it is used for idempotency, but that's incorrect… besides logging, our API just ignores this /cc @pedroalves0, let's tweak or clean up those comments?
A note about removing
tests/test_api_async.py: I hadn't yet come across this test file, but I found it pretty useless. It's validating howTodoistAPIAsyncinvokes theTodoistAPIconstructor correctly, but that's an implementation detail. All test files and functions that test actual behavior do it across bothTodoistAPIandTodoistAPIAsync. That's actually valuable, unlike testing constructor internals.