-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requests
: Allow session headers to be of type None
#7773
Changes from 4 commits
d9ca9a7
249ce7c
0602cc3
b1ad88d
9996858
3368ce6
0e8ff7e
b5ec834
6f7eb28
f9aaf0c
0d80bdf
072c537
f189735
ccb434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,12 +67,14 @@ _Params: TypeAlias = Union[ | |
str | bytes, | ||
] | ||
_TextMapping: TypeAlias = MutableMapping[str, str] | ||
_HeadersMapping = TypeAlias = MutableMapping[str, str | bytes] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is inconvenient because MutableMapping is invariant in its value type, so a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about MutableMapping[str, str] | MutableMapping[str, bytes] ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
_HeadersUpdateMapping: TypeAlias = _HeadersMapping | MutableMapping[str, None] | ||
_Timeout: TypeAlias = Union[float, tuple[float, float], tuple[float, None]] | ||
_Verify: TypeAlias = bool | str | ||
|
||
class Session(SessionRedirectMixin): | ||
__attrs__: Any | ||
headers: CaseInsensitiveDict[str | None] | ||
headers: CaseInsensitiveDict[str | bytes] | ||
auth: _Auth | None | ||
proxies: _TextMapping | ||
hooks: _Hooks | ||
|
@@ -95,7 +97,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 +116,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 +135,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 +154,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 +174,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 +192,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 +211,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 +230,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 = ..., | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is correct? These headers are from the HTTP response, and I'd expect requests to return the same type consistently.
This seems to be the cause of a false positive on this line found by mypy-primer: https://github.com/yurijmikhalevich/rclip/blob/98a2454b988986f6ed67ae6e9fe3342ea82e0f92/rclip/utils.py#L92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right: https://github.com/psf/requests/blob/40956723f27daf5e0d9759208ca69cef236ab339/requests/models.py#L484
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6f7eb28