Skip to content

Fix requests.Session().hooks - #7871

Merged
JelleZijlstra merged 3 commits into
masterfrom
Akuli-patch-1
May 19, 2022
Merged

JelleZijlstra merged 3 commits into
masterfrom
Akuli-patch-1

Conversation

@Akuli

@Akuli Akuli commented May 18, 2022

Copy link
Copy Markdown
Collaborator

Fixes #7776

Mutating hooks, as in session.hooks['response'] = ..., should work. Reassigning it like session.hooks = ... is probably a bad idea, so it will always be a dict.

Fixes #7776

Mutating hooks, as in `session.hooks['response'] = ...`, should work. Reassigning it like `session.hooks = ...` is probably a bad idea, so it will always be a `dict`.
@Akuli
Akuli marked this pull request as draft May 18, 2022 21:40
@Akuli

Akuli commented May 18, 2022

Copy link
Copy Markdown
Collaborator Author

We still need to discuss whether it's better to use a union or just require hooks to be lists. The usual reason for avoiding union return types applies here: if we merge this PR as is, #7776 still wouldn't work, because it would end up calling .append() on a _Hook | list[_Hook]. #7776 (comment)

@Akuli Akuli changed the title Use dict for requests.Session().hooks Fix requests.Session().hooks May 18, 2022
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli
Akuli marked this pull request as ready for review May 18, 2022 21:59

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense

@JelleZijlstra
JelleZijlstra merged commit 9a09db4 into master May 19, 2022
@JelleZijlstra
JelleZijlstra deleted the Akuli-patch-1 branch May 19, 2022 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in requests hooks stubs

3 participants