-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Title: Change get_auth signature: replace *_ with * to avoid untyped varargs
Summary:
Please change the get_auth function signature to use a bare * instead of *_, so that the function requires keyword-only args without introducing an untyped varargs parameter.
Why:
- Currently
get_authis defined asdef get_auth(*_, client_id: str, ...)which accepts arbitrary positional args via*_. - The untyped varargs show up to type-checkers (Pylance/Pyright) as
Unknownand leads to diagnostics likereportUnknownVariableTypein consumer projects (even whenpython.analysis.useLibraryCodeForTypesis enabled). - Replacing
*_,with*keeps the function semantics (forces subsequent parameters to be keyword-only) without introducing an untyped parameter that causes analyzer warnings.
Suggested one-line change in fastapi_oidc/auth.py:
- def get_auth(*_, client_id: str, audience: Optional[str] = None, base_authorization_server_uri: str, issuer: str, signature_cache_ttl: int, token_type: Type[IDToken] = IDToken) -> Callable[[str], IDToken]:
+ def get_auth(*, client_id: str, audience: Optional[str] = None, base_authorization_server_uri: str, issuer: str, signature_cache_ttl: int, token_type: Type[IDToken] = IDToken) -> Callable[[str], IDToken]:Notes:
- This change is non-breaking: it still forces the same keyword-only parameters, but removes the untyped
*_varargs tuple that static analyzers flag asUnknown. - If maintainers prefer an explicit typed varargs,
*_: Anyis an alternative that keeps a positional capture but types it explicitly for analyzers.
Can I open a PR with this small change (and optional *_: Any variant) if youd
Metadata
Metadata
Assignees
Labels
No labels