Add typing for serializable JSON values.

Review Request #13253 — Created Sept. 3, 2023 and submitted — Latest diff uploaded

Information

Djblets
release-4.x

Reviewers

Djblets 3.3 gained standard types for standard JSON values, which is
great when deserializing. However, when preparing data to be serialized
to JSON, we often need to work with datetimes, lazy strings, UUIDs, and
objects that can be serialized to JSON.

To address this, we now have a new "serializable" set of JSON types,
which support all the values that DjbletsJSONEncoder (and parent
classes) support. This includes, date, time, datetime,
timedelta, UUID, Promise, and Decimal values, along with
functions containing a to_json() method.

DjbletsJSONEncoder has been updated to include the typing support as
well, primarily for consistency and to help test the types. It also
drops explicit support for Promise (lazy strings), since Django's
encoder supports that internally these days.

Also of note, this does not contain typing used by the WebAPI resource
support. These types only work with this encoder and not the resource
encoder.

Unit tests pass in Djblets and Review Board.

Made use of these new types in some in-progress code.

Commits

Files