From 5b0e66c4574b8cd00f42faaf8165bf562ad37204 Mon Sep 17 00:00:00 2001 From: dhairya05 Date: Fri, 6 Nov 2026 21:36:57 +0530 Subject: [PATCH] [www-authenticate] Annotate `parse`'s return value type `parse` returned `CaseFoldedOrderedDict[Incomplete]`. The value stored for each challenge is decided by one line of the implementation: challenges[name] = (args and args[0]) or kwargs or None so it is the single token when the challenge carries one, the parsed key/value parameters otherwise, and None when the challenge is bare. Checked against www-authenticate 0.9.2: >>> parse('Basic realm="a", Bearer, Negotiate abc==') CaseFoldedOrderedDict([('basic', {'realm': 'a'}), ('bearer', None), ('negotiate', 'abc==')]) Annotated as `str | dict[str, str] | None`, which lets callers narrow the three cases instead of getting `Any`. --- stubs/www-authenticate/www_authenticate.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/www-authenticate/www_authenticate.pyi b/stubs/www-authenticate/www_authenticate.pyi index 392bee206f6d..a72e2619b479 100644 --- a/stubs/www-authenticate/www_authenticate.pyi +++ b/stubs/www-authenticate/www_authenticate.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections import OrderedDict from typing import Protocol, TypeVar, overload, type_check_only @@ -33,4 +32,4 @@ class CaseFoldedOrderedDict(OrderedDict[str, _VT]): @overload def pop(self, key: _SupportsCasefold | _SupportsLower, default: _T) -> _VT | _T: ... -def parse(value: str) -> CaseFoldedOrderedDict[Incomplete]: ... +def parse(value: str) -> CaseFoldedOrderedDict[str | dict[str, str] | None]: ...