• 
      

    Add type annotations to djblets.secrets.

    Review Request #12703 — Created Nov. 1, 2022 and submitted

    Information

    Djblets
    release-3.x

    Reviewers

    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 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
    uses ExceptionFreeGetterMixin, the get() method will continue to
    allow None results, at the expense of type safety warnings where the
    overridden 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.
    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
    Add type annotations to djblets.secrets.
    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 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 uses `ExceptionFreeGetterMixin`, the `get()` method will continue to allow `None` results, at the expense of type safety warnings where the overridden `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. Internally, `Registry.get_or_none()` is now used.
    ff2fc53bf39589bde55e811502af7284508e7803
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.x (0d0298f)