Add type hints and keyword-only arguments for djblets.webapi.responses.

Review Request #12724 — Created Nov. 14, 2022 and submitted

Information

Djblets
release-3.x

Reviewers

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 if queryset was None, or when passing obj 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
Add type hints and keyword-only arguments for djblets.webapi.responses.
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 if `queryset` was `None`, or when passing `obj` to the constructor. Both have been fixed. Some unit tests have been added for construction, but many tests are still lacking.
3d458a0f7451b7c98da3bd5c7915d6809f927e40
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.x (edfb48a)
Loading...