8000 Fix requests.Session().hooks by Akuli · Pull Request #7871 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Fix requests.Session().hooks #7871

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

Merged
merged 3 commits into from
May 19, 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
Next Next commit
Use dict for requests.Session().hooks
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`.
  • Loading branch information
Akuli authored May 18, 2022
commit 0659341068b6ff0c06a539a88d6fdd48fd20f654
2 changes: 1 addition & 1 deletion stubs/requests/requests/sessions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ _Files: TypeAlias = (
| Mapping[str, tuple[str | None, SupportsRead[str | bytes] | str | bytes, str, _TextMapping]]
)
_Hook: TypeAlias = Callable[[Response], Any]
_Hooks: TypeAlias = Mapping[str, _Hook | list[_Hook]]
_Hooks: TypeAlias = dict[str, _Hook | list[_Hook]]
_HooksInput: TypeAlias = Mapping[str, Iterable[_Hook] | _Hook]

_ParamsMappingKeyType: TypeAlias = str | bytes | int | float
Expand Down
0