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

Allow List[str] for requests.Session.request(params=) #5187

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

sathieu
Copy link
Contributor

@sathieu sathieu commented Apr 7, 2021

From source:

        #: Dictionary of querystring data to attach to each
        #: :class:`Request <Request>`. The dictionary values may be lists for
        #: representing multivalued query parameters.
        self.params = {}

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, looks good, syntax aside! I also checked that the comment is up to date: https://github.com/psf/requests/blob/2c2138e811487b13020eb331482fb991fd399d4e/requests/models.py#L97

@sathieu
Copy link
Contributor Author

sathieu commented Apr 7, 2021

@hauntsaninja I've fixed the syntax and added the same annotation to the attribute.

@sathieu
Copy link
Contributor Author

sathieu commented Apr 7, 2021

Also from doc:

You can also pass a list of items as a value:

>>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}

>>> r = requests.get('https://httpbin.org/get', params=payload)
>>> print(r.url)
https://httpbin.org/get?key1=value1&key2=value2&key2=value3

@hauntsaninja
Copy link
Collaborator

Thanks! :-)

@hauntsaninja hauntsaninja merged commit cb03e90 into python:master Apr 7, 2021
@Akuli
Copy link
Collaborator

Akuli commented Apr 7, 2021

I wonder if it still accepts Dict[str, str], as the value type of MutableMapping is invariant.

@hauntsaninja
Copy link
Collaborator

Oh that's a good point. We should probably just steal the type from

params: Optional[

@srittau
Copy link
Collaborator

srittau commented Apr 7, 2021

Minor nit for future reference: built-in generics are now mostly supported in typeshed (#4820) and should be used over the generics from typing where possible.

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.

None yet

4 participants