Add type hints and keyword-only arguments for djblets.webapi.responses.
Review Request #12724 — Created Nov. 14, 2022 and submitted
The
djblets.webapi.responses
classes (WebAPIResponse
,
WebAPIResponsePaginated
,WebAPIResponseError
,
WebAPIResponseFormError
) are core to our API code. These convert
internal structured API response data to payloads for the client.Although this code rarely needs to change, much of this code is very
old, in need of some love, and in need of unit testing.To assist in some in-progress work on the API and code using the API,
this change adds type hints to this code, and changes constructors to
require keyword-only arguments (with deprecated compatibility with
positional arguments).In the process, the documentation for these classes have been fleshed
out.This did uncover some flaws in
WebAPIResponsePaginated
where various
methods would crash ifqueryset
wasNone
, or when passingobj
to
the constructor. Both have been fixed.Some unit tests have been added for construction, but many tests are
still lacking.
All unit tests pass.
No issues reported by mypy or pyright.
Summary | ID |
---|---|
3d458a0f7451b7c98da3bd5c7915d6809f927e40 |