Add utility modules for common types and symbols.

Review Request #13111 — Created June 16, 2023 and submitted — Latest diff uploaded




The new djblets.util.typing module includes some standard types for
JSON data, keyword argument dictionaries, and safe aliases for
django-stubs StrOrPromise implementations.

The new JSON types are enhanced versions of our old ones. Modern
versions of mypy and pyright offer recursive type checks, meaning we can
now have deep JSON structures that still type correctly.

The StrOrPromise/StrPromise types alias the ones in django-stubs
when type checking, and otherwise fall back to an approximation. This
mostly mirrors what the django_stubs_ext module gives us (which they
recommend for type checks), but then we'd have to depend on that at
runtime. Plus, this a bit of a better/more correctly typed

The new djblets.util.symbols module gives us common symbols we can use
elsewhere. For now, this provides an UNSET symbol, useful as default
arguments for other functions where it's important to differentiate from
unset and None.

Other modules have been updated to use some of these where appropriate.
Not all of this is currently in use within Djblets, but future changes
will build off of these.

Unit tests pass for all supported versions of Python.

Made use of these in some upcoming changes.

Built some test code to ensure that the types were being interpreted
correctly, in particular the recursive JSON typing.