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.session().headers #9390

Closed
evilensky opened this issue Dec 21, 2022 · 2 comments · Fixed by #9395
Closed

requests.session().headers #9390

evilensky opened this issue Dec 21, 2022 · 2 comments · Fixed by #9395
Labels
stubs: false positive Type checkers report false errors

Comments

@evilensky
Copy link
Contributor

evilensky commented Dec 21, 2022

According to this comment in the requests project:

We deliberately allow any mapping type to allow for a variety of use-cases. A change here won't be accepted

I think this means that the strict typing shown here is not correct:

https://github.com/python/typeshed/blob/main/stubs/requests/requests/sessions.pyi#L116

And instead something that satisfies a mutableMapping would be more correct?

The X to my Y problem is that I am very much used to working with .headers set to a built-in dict. And if it works and is supported by requests , could I submit a patch to the type stubs? Satisfying this typing constraint as it is right now feels incorrect given the long history of the dict() being sufficient.

@srittau
Copy link
Collaborator

srittau commented Dec 21, 2022

For reference, this was changed in #3043, where the problems was that session.headers.copy() didn't work. But according to @sigmavirus24's comment, this is not guaranteed to work, so changing it back like you suggested sounds like a good idea to me.

@evilensky
Copy link
Contributor Author

I gave it my best shot in the referenced pull request. thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants