Add type hints for webapi auth backends, and fix minor issues.
Review Request #12725 — Created Nov. 15, 2022 and submitted
This adds type hints throughout
djblets.webapi.auth.backends
. Return
types are now properly standardized and documented, as are credential
arguments. This will give us a path forward if we want to enhance these,
and aids in implementing backends in consuming codebases.Token authentication, which uses both a webapi auth backend and a Django
auth backend with avalidate_token()
method, now has that relationship
clearly defined through use of Protocols, a typing feature to help with
duck typing. It also skips calling this method if there's no token to
validate, which can avoid problems in backends.Some places where we were directly setting, deleting, or retrieving
custom Django-namespaced properties now usessetattr()
,getattr()
,
anddelattr()
, to avoid attribute errors during type checks.
All unit tests pass in all supported versions of Python.
Summary | ID |
---|---|
53f016bd32152d8cdd175a0982e2552dcb2c1ac8 |
Description | From | Last Updated |
---|---|---|
'typing.TYPE_CHECKING' imported but unused Column: 1 Error code: F401 |
reviewbot |