Document that 'data' can be a list of tuples everywhere
Before adoption: this commit came in with the history the project adopted, so no landing records it.
The documentation for the 'data' parameter of various functions was inconsistant. The low-level function, used by every convenience API, internally uses RequestEncodingMixin._encode_params which accepts list of tuples as well as dictionaries, hence every function taking a data parameter also accepts a list of tuple. Keep the documentation short, but provide a link to Request for details.
authored by Matthieu Moy · committed by Matthieu Moy · parent f6e13cc · Browse files · 3 files·+19 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+19 added−10 removed
- other:+19 added−10 removed
Provenance
- Commit
2d1b448- Tree
7c8bda9- Author
Matthieu Moy <git@matthieu-moy.fr>- Committer
Matthieu Moy <git@matthieu-moy.fr>- Parent
f6e13cc
3 files changed+19 added−10 removed
modified:requests/api.py+8 added-4 removed
17 unmodified lines18 19 :param method: method for the new :class:`Request` object.20 :param url: URL for the new :class:`Request` object.21 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.22- :param data: (optional) Dictionary or list of tuples ``[(key, value)]`` (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.22+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like23+ object to send in the body of the :class:`Request`.24 :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.25 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.26 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.27 :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.74 unmodified lines102 def post(url, data=None, json=None, **kwargs):103 r"""Sends a POST request.104 105 :param url: URL for the new :class:`Request` object.105- :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.106+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like107+ object to send in the body of the :class:`Request`.108 :param json: (optional) json data to send in the body of the :class:`Request`.109 :param \*\*kwargs: Optional arguments that ``request`` takes.110 :return: :class:`Response <Response>` object111 :rtype: requests.Response5 unmodified lines117 def put(url, data=None, **kwargs):118 r"""Sends a PUT request.119 120 :param url: URL for the new :class:`Request` object.119- :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.121+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like122+ object to send in the body of the :class:`Request`.123 :param json: (optional) json data to send in the body of the :class:`Request`.124 :param \*\*kwargs: Optional arguments that ``request`` takes.125 :return: :class:`Response <Response>` object126 :rtype: requests.Response5 unmodified lines132 def patch(url, data=None, **kwargs):133 r"""Sends a PATCH request.134 135 :param url: URL for the new :class:`Request` object.133- :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.136+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like137+ object to send in the body of the :class:`Request`.138 :param json: (optional) json data to send in the body of the :class:`Request`.139 :param \*\*kwargs: Optional arguments that ``request`` takes.140 :return: :class:`Response <Response>` object141 :rtype: requests.Response15 unmodified linesmodified:requests/models.py+3 added-1 removed
202 unmodified lines203 :param method: HTTP method to use.204 :param url: URL to send.205 :param headers: dictionary of headers to send.206 :param files: dictionary of {filename: fileobject} files to multipart upload.207- :param data: the body to attach to the request. If a dictionary is provided, form-encoding will take place.207+ :param data: the body to attach to the request. If a dictionary or208+ list of tuples ``[(key, value)]`` is provided, form-encoding will209+ take place.210 :param json: json for the body to attach to the request (if files or data is not specified).211 :param params: dictionary of URL parameters to append to the URL.212 :param auth: Auth handler or (user, pass) tuple.213 :param cookies: dictionary or CookieJar of cookies to attach to this request.741 unmodified linesmodified:requests/sessions.py+8 added-5 removed
451 unmodified lines452 :param method: method for the new :class:`Request` object.453 :param url: URL for the new :class:`Request` object.454 :param params: (optional) Dictionary or bytes to be sent in the query455 string for the :class:`Request`.456- :param data: (optional) Dictionary, bytes, or file-like object to send457- in the body of the :class:`Request`.456+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like457+ object to send in the body of the :class:`Request`.458 :param json: (optional) json to send in the body of the459 :class:`Request`.460 :param headers: (optional) Dictionary of HTTP Headers to send with the461 :class:`Request`.87 unmodified lines549 def post(self, url, data=None, json=None, **kwargs):550 r"""Sends a POST request. Returns :class:`Response` object.551 552 :param url: URL for the new :class:`Request` object.553- :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.553+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like554+ object to send in the body of the :class:`Request`.555 :param json: (optional) json to send in the body of the :class:`Request`.556 :param \*\*kwargs: Optional arguments that ``request`` takes.557 :rtype: requests.Response558 """3 unmodified lines562 def put(self, url, data=None, **kwargs):563 r"""Sends a PUT request. Returns :class:`Response` object.564 565 :param url: URL for the new :class:`Request` object.565- :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.566+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like567+ object to send in the body of the :class:`Request`.568 :param \*\*kwargs: Optional arguments that ``request`` takes.569 :rtype: requests.Response570 """571 2 unmodified lines574 def patch(self, url, data=None, **kwargs):575 r"""Sends a PATCH request. Returns :class:`Response` object.576 577 :param url: URL for the new :class:`Request` object.576- :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.578+ :param data: (optional) Dictionary, list of tuples, bytes, or file-like579+ object to send in the body of the :class:`Request`.580 :param \*\*kwargs: Optional arguments that ``request`` takes.581 :rtype: requests.Response582 """583 166 unmodified lines