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
A lot of new typing for
requestswas 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
_Filesshould beOptional[str]:typeshed/stubs/requests/requests/sessions.pyi
Lines 51 to 56 in bfa9188
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
filenamepassed tourllib3.fields.RequestField, which is typed as optional:https://github.com/urllib3/urllib3/blob/e16beb210c03c6f5ce4e0908bddb6556442b6a37/src/urllib3/fields.py#L178-L185