Add type annotations to djblets.secrets.
Review Request #12703 — Created Nov. 1, 2022 and submitted
Much of the code in
djblets.secrets
is 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 ofdjblets.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
usesExceptionFreeGetterMixin
, theget()
method will continue to
allowNone
results, at the expense of type safety warnings where the
overriddenget()
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.
Internally,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
Registry.get()
method.
Summary | ID |
---|---|
ff2fc53bf39589bde55e811502af7284508e7803 |