Skip to content
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

Merged
merged 14 commits into from
May 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/requests/requests/sessions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _Verify: TypeAlias = bool | str

class Session(SessionRedirectMixin):
__attrs__: Any
headers: CaseInsensitiveDict[str]
headers: CaseInsensitiveDict[str | None]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in https://docs.python-requests.org/en/latest/user/quickstart/#custom-headers , header values can also be bytestring.

Suggested change
headers: CaseInsensitiveDict[str | None]
headers: CaseInsensitiveDict[str | bytes | None]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I think I added None to the wrong place. We want to allow str or bytes on actual headers, but None only on updates

auth: _Auth | None
proxies: _TextMapping
hooks: _Hooks
Expand Down