Typechecking this program ```python import requests session = requests.Session() session.hooks = { 'response': lambda r, *args, **kwargs: r.raise_for_status() } ``` fails with ``` foo.py:5: error: Dict entry 0 has incompatible type "str": "Callable[[Any, VarArg(Any), KwArg(Any)], Any]"; expected "str": "List[Callable[[Response], Any]]" Found 1 error in 1 file (checked 1 source file) ``` although the code works. Changing [this](https://github.com/python/typeshed/blob/master/stubs/requests/requests/sessions.pyi#L53) line to ``` _Hooks = MutableMapping[Text, Union[_Hook,list[_Hook]]] ``` fixes this for me. Should I open a pull request?
Activity
srittau commentedon Jan 31, 2022
Sounds right to me (except that we use
|syntax instead ofUnionin typeshed). PR welcome!