Add utility modules for common types and symbols.
Review Request #13111 — Created June 16, 2023 and submitted
djblets.util.typingmodule includes some standard types for
JSON data, keyword argument dictionaries, and safe aliases for
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.
StrPromisetypes alias the ones in
when type checking, and otherwise fall back to an approximation. This
mostly mirrors what the
django_stubs_extmodule 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
djblets.util.symbolsmodule gives us common symbols we can use
elsewhere. For now, this provides an
UNSETsymbol, useful as default
arguments for other functions where it's important to differentiate from
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.
StrPromiseruntime type alias to avoid a weird issue with Sphinx doc generation.
Revision 2 (+234 -30)
Checks run (2 succeeded)