Skip to content

Change get_auth signature: replace '*_' with '*' to avoid untyped varargs #52

@stoyan-atanasov-beye

Description

@stoyan-atanasov-beye

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_auth is defined as def get_auth(*_, client_id: str, ...) which accepts arbitrary positional args via *_.
  • The untyped varargs show up to type-checkers (Pylance/Pyright) as Unknown and leads to diagnostics like reportUnknownVariableType in consumer projects (even when python.analysis.useLibraryCodeForTypes is 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 as Unknown.
  • If maintainers prefer an explicit typed varargs, *_: Any is 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions