Add type annotations to djblets.secrets.
Review Request #12703 — Created Nov. 1, 2022 and submitted
Much of the code in
djblets.secretsis type-specific, particularly the
crypto-related code. It's important to get this right, and there's new
in-progress code being developed that uses these methods.
To ensure everything works smoothly, this change adds type annotations
to all of
djblets.secrets. This includes the crypto method and all the
token generator code.
The token generator registry now uses the new typed registries support,
ensuring type safety for all items in the registry. Since this registry
get()method will continue to
Noneresults, at the expense of type safety warnings where the
get()doesn't match the original function signature.
Ideally, we'd remove this mixin, but we'd need to go through a
deprecation cycle for the old behavior, and it isn't worth it right now.
Registry.get_or_none()is now used.
Unit tests pass for all supported versions of Python.
mypy and pyright are largely happy, with the exception of the overridden