diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index ee6f446e5ca5..0006f6851bfa 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -1,7 +1,19 @@ from typing import Any from .models import Response -from .sessions import RequestsCookieJar, _Auth, _Cert, _Data, _Files, _HooksInput, _Params, _TextMapping, _Timeout, _Verify +from .sessions import ( + RequestsCookieJar, + _Auth, + _Cert, + _Data, + _Files, + _HeadersMapping, + _HooksInput, + _Params, + _TextMapping, + _Timeout, + _Verify, +) def request( method: str | bytes, @@ -9,7 +21,7 @@ def request( *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -27,7 +39,7 @@ def get( params: _Params | None = ..., *, data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -45,7 +57,7 @@ def options( *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -63,7 +75,7 @@ def head( *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -82,7 +94,7 @@ def post( json: Any | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -99,7 +111,7 @@ def put( data: _Data | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -117,7 +129,7 @@ def patch( data: _Data | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -135,7 +147,7 @@ def delete( *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index a0143f60e3d6..49c69d3da6a6 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -67,12 +67,22 @@ _Params: TypeAlias = Union[ str | bytes, ] _TextMapping: TypeAlias = MutableMapping[str, str] +_HeadersMapping: TypeAlias = MutableMapping[str, str] | MutableMapping[str, bytes] | MutableMapping[str, str | bytes] +_HeadersUpdateMapping: TypeAlias = ( + MutableMapping[str, str] + | MutableMapping[str, bytes] + | MutableMapping[str, None] + | MutableMapping[str, str | bytes] + | MutableMapping[str, str | None] + | MutableMapping[str, bytes | None] + | MutableMapping[str, str | bytes | None] +) _Timeout: TypeAlias = Union[float, tuple[float, float], tuple[float, None]] _Verify: TypeAlias = bool | str class Session(SessionRedirectMixin): __attrs__: Any - headers: CaseInsensitiveDict[str] + headers: CaseInsensitiveDict[str | bytes] auth: _Auth | None proxies: _TextMapping hooks: _Hooks @@ -95,7 +105,7 @@ class Session(SessionRedirectMixin): url: str | bytes, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: None | RequestsCookieJar | _TextMapping = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -114,7 +124,7 @@ class Session(SessionRedirectMixin): *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -133,7 +143,7 @@ class Session(SessionRedirectMixin): *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -152,7 +162,7 @@ class Session(SessionRedirectMixin): *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -172,7 +182,7 @@ class Session(SessionRedirectMixin): json: Any | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -190,7 +200,7 @@ class Session(SessionRedirectMixin): data: _Data | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -209,7 +219,7 @@ class Session(SessionRedirectMixin): data: _Data | None = ..., *, params: _Params | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ..., @@ -228,7 +238,7 @@ class Session(SessionRedirectMixin): *, params: _Params | None = ..., data: _Data | None = ..., - headers: _TextMapping | None = ..., + headers: _HeadersUpdateMapping | None = ..., cookies: RequestsCookieJar | _TextMapping | None = ..., files: _Files | None = ..., auth: _Auth | None = ...,