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

Incorrect Requests Typing #7720

Closed
AlecRosenbaum opened this issue Apr 27, 2022 · 1 comment · Fixed by #7721
Closed

Incorrect Requests Typing #7720

AlecRosenbaum opened this issue Apr 27, 2022 · 1 comment · Fixed by #7721

Comments

@AlecRosenbaum
Copy link
Contributor

AlecRosenbaum commented Apr 27, 2022

A lot of new typing for requests was introduced with #7696. This is great! Except there's a minor bug that doesn't line up with requests actual accepted types.

The first element of the tuples for _Files should be Optional[str]:

_Files: TypeAlias = (
MutableMapping[str, IO[Any]]
| MutableMapping[str, tuple[str, IO[Any]]]
| MutableMapping[str, tuple[str, IO[Any], str]]
| MutableMapping[str, tuple[str, IO[Any], str, _TextMapping]]
)

The files arg is passed through a bunch of layers within requests and eventually actually handled here:
https://github.com/psf/requests/blob/fa1b0a367abc8488542f7ce7c02a3614ad8aa09d/requests/models.py#L143-L169

The first arg of a tuple becomes the filename passed to urllib3.fields.RequestField, which is typed as optional:
https://github.com/urllib3/urllib3/blob/e16beb210c03c6f5ce4e0908bddb6556442b6a37/src/urllib3/fields.py#L178-L185

@Akuli
Copy link
Collaborator

Akuli commented Apr 27, 2022

PR welcome!

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 a pull request may close this issue.

2 participants