query_params -> params
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tom Christie · committed by Tom Christie · parent f63148a · Browse files · 5 files·+52 added−50 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+52 added−50 removed
- tests:+3 added−3 removed
- other:+49 added−47 removed
Provenance
- Commit
c6287ed- Tree
a9cc7bf- Author
Tom Christie <tom@tomchristie.com>- Committer
Tom Christie <tom@tomchristie.com>- Parent
f63148a
5 files changed+52 added−50 removed
modified:httpcore/client.py+31 added-27 removed
56 unmodified lines57 async def get(58 self,59 url: URLTypes,60 *,61- query_params: QueryParamTypes = None,61+ params: QueryParamTypes = None,62 headers: HeaderTypes = None,63 cookies: CookieTypes = None,64 stream: bool = False,65 auth: AuthTypes = None,3 unmodified lines69 ) -> Response:70 return await self.request(71 "GET",72 url,73- query_params=query_params,73+ params=params,74 headers=headers,75 cookies=cookies,76 stream=stream,77 auth=auth,5 unmodified lines83 async def options(84 self,85 url: URLTypes,86 *,87- query_params: QueryParamTypes = None,87+ params: QueryParamTypes = None,88 headers: HeaderTypes = None,89 cookies: CookieTypes = None,90 stream: bool = False,91 auth: AuthTypes = None,3 unmodified lines95 ) -> Response:96 return await self.request(97 "OPTIONS",98 url,99- query_params=query_params,99+ params=params,100 headers=headers,101 cookies=cookies,102 stream=stream,103 auth=auth,5 unmodified lines109 async def head(110 self,111 url: URLTypes,112 *,113- query_params: QueryParamTypes = None,113+ params: QueryParamTypes = None,114 headers: HeaderTypes = None,115 cookies: CookieTypes = None,116 stream: bool = False,117 auth: AuthTypes = None,3 unmodified lines121 ) -> Response:122 return await self.request(123 "HEAD",124 url,125- query_params=query_params,125+ params=params,126 headers=headers,127 cookies=cookies,128 stream=stream,129 auth=auth,6 unmodified lines136 self,137 url: URLTypes,138 *,139 data: RequestData = b"",140- query_params: QueryParamTypes = None,140+ params: QueryParamTypes = None,141 headers: HeaderTypes = None,142 cookies: CookieTypes = None,143 stream: bool = False,144 auth: AuthTypes = None,4 unmodified lines149 return await self.request(150 "POST",151 url,152 data=data,153- query_params=query_params,153+ params=params,154 headers=headers,155 cookies=cookies,156 stream=stream,157 auth=auth,6 unmodified lines164 self,165 url: URLTypes,166 *,167 data: RequestData = b"",168- query_params: QueryParamTypes = None,168+ params: QueryParamTypes = None,169 headers: HeaderTypes = None,170 cookies: CookieTypes = None,171 stream: bool = False,172 auth: AuthTypes = None,4 unmodified lines177 return await self.request(178 "PUT",179 url,180 data=data,181- query_params=query_params,181+ params=params,182 headers=headers,183 cookies=cookies,184 stream=stream,185 auth=auth,6 unmodified lines192 self,193 url: URLTypes,194 *,195 data: RequestData = b"",196- query_params: QueryParamTypes = None,196+ params: QueryParamTypes = None,197 headers: HeaderTypes = None,198 cookies: CookieTypes = None,199 stream: bool = False,200 auth: AuthTypes = None,4 unmodified lines205 return await self.request(206 "PATCH",207 url,208 data=data,209- query_params=query_params,209+ params=params,210 headers=headers,211 cookies=cookies,212 stream=stream,213 auth=auth,6 unmodified lines220 self,221 url: URLTypes,222 *,223 data: RequestData = b"",224- query_params: QueryParamTypes = None,224+ params: QueryParamTypes = None,225 headers: HeaderTypes = None,226 cookies: CookieTypes = None,227 stream: bool = False,228 auth: AuthTypes = None,4 unmodified lines233 return await self.request(234 "DELETE",235 url,236 data=data,237- query_params=query_params,237+ params=params,238 headers=headers,239 cookies=cookies,240 stream=stream,241 auth=auth,7 unmodified lines249 method: str,250 url: URLTypes,251 *,252 data: RequestData = b"",253- query_params: QueryParamTypes = None,253+ params: QueryParamTypes = None,254 headers: HeaderTypes = None,255 cookies: CookieTypes = None,256 stream: bool = False,257 auth: AuthTypes = None,4 unmodified lines262 request = Request(263 method,264 url,265 data=data,266- query_params=query_params,266+ params=params,267 headers=headers,268 cookies=self.merge_cookies(cookies),269 )270 self.prepare_request(request)9 unmodified lines280 281 def prepare_request(self, request: Request) -> None:282 request.prepare()283 284- def merge_cookies(self, cookies: CookieTypes = None) -> typing.Optional[CookieTypes]:284+ def merge_cookies(285+ self, cookies: CookieTypes = None286+ ) -> typing.Optional[CookieTypes]:287 if cookies or self.cookies:288 merged_cookies = Cookies(self.cookies)289 merged_cookies.update(cookies)290 return merged_cookies87 unmodified lines378 url = self.redirect_url(request, response)379 headers = self.redirect_headers(request, url)380 content = self.redirect_content(request, method)381 cookies = self.merge_cookies(request.cookies)380- return Request(method=method, url=url, headers=headers, data=content, cookies=cookies)382+ return Request(383+ method=method, url=url, headers=headers, data=content, cookies=cookies384+ )385 386 def redirect_method(self, request: Request, response: Response) -> str:387 """388 When being redirected we may want to change the method of the request102 unmodified lines491 method: str,492 url: URLTypes,493 *,494 data: RequestData = b"",491- query_params: QueryParamTypes = None,495+ params: QueryParamTypes = None,496 headers: HeaderTypes = None,497 cookies: CookieTypes = None,498 stream: bool = False,499 auth: AuthTypes = None,4 unmodified lines504 request = Request(505 method,506 url,507 data=data,504- query_params=query_params,508+ params=params,509 headers=headers,510 cookies=self._client.merge_cookies(cookies),511 )512 self.prepare_request(request)10 unmodified lines523 def get(524 self,525 url: URLTypes,526 *,523- query_params: QueryParamTypes = None,527+ params: QueryParamTypes = None,528 headers: HeaderTypes = None,529 cookies: CookieTypes = None,530 stream: bool = False,531 auth: AuthTypes = None,16 unmodified lines548 def options(549 self,550 url: URLTypes,551 *,548- query_params: QueryParamTypes = None,552+ params: QueryParamTypes = None,553 headers: HeaderTypes = None,554 cookies: CookieTypes = None,555 stream: bool = False,556 auth: AuthTypes = None,16 unmodified lines573 def head(574 self,575 url: URLTypes,576 *,573- query_params: QueryParamTypes = None,577+ params: QueryParamTypes = None,578 headers: HeaderTypes = None,579 cookies: CookieTypes = None,580 stream: bool = False,581 auth: AuthTypes = None,17 unmodified lines599 self,600 url: URLTypes,601 *,602 data: RequestData = b"",599- query_params: QueryParamTypes = None,603+ params: QueryParamTypes = None,604 headers: HeaderTypes = None,605 cookies: CookieTypes = None,606 stream: bool = False,607 auth: AuthTypes = None,18 unmodified lines626 self,627 url: URLTypes,628 *,629 data: RequestData = b"",626- query_params: QueryParamTypes = None,630+ params: QueryParamTypes = None,631 headers: HeaderTypes = None,632 cookies: CookieTypes = None,633 stream: bool = False,634 auth: AuthTypes = None,18 unmodified lines653 self,654 url: URLTypes,655 *,656 data: RequestData = b"",653- query_params: QueryParamTypes = None,657+ params: QueryParamTypes = None,658 headers: HeaderTypes = None,659 cookies: CookieTypes = None,660 stream: bool = False,661 auth: AuthTypes = None,18 unmodified lines680 self,681 url: URLTypes,682 *,683 data: RequestData = b"",680- query_params: QueryParamTypes = None,684+ params: QueryParamTypes = None,685 headers: HeaderTypes = None,686 cookies: CookieTypes = None,687 stream: bool = False,688 auth: AuthTypes = None,55 unmodified linesmodified:httpcore/interfaces.py+2 added-4 removed
36 unmodified lines37 method: str,38 url: URLTypes,39 *,40 data: RequestData = b"",41- query_params: QueryParamTypes = None,41+ params: QueryParamTypes = None,42 headers: HeaderTypes = None,43 stream: bool = False,44 ssl: SSLConfig = None,45 timeout: TimeoutConfig = None46 ) -> Response:47- request = Request(48- method, url, data=data, query_params=query_params, headers=headers49- )47+ request = Request(method, url, data=data, params=params, headers=headers)48 self.prepare_request(request)49 response = await self.send(request, stream=stream, ssl=ssl, timeout=timeout)50 return response51 81 unmodified linesmodified:httpcore/models.py+6 added-6 removed
63 unmodified lines64 def __init__(65 self,66 url: URLTypes,67 allow_relative: bool = False,68- query_params: QueryParamTypes = None,68+ params: QueryParamTypes = None,69 ) -> None:70 if isinstance(url, rfc3986.uri.URIReference):71 self.components = url72 elif isinstance(url, str):10 unmodified lines83 # Normalize scheme and domain name.84 self.components = self.components.normalize()85 86 # Add any query parameters.87- if query_params:88- query_string = str(QueryParams(query_params))87+ if params:88+ query_string = str(QueryParams(params))89 self.components = self.components.copy_with(query=query_string)90 91 # Enforce absolute URLs by default.92 if not allow_relative:386 unmodified lines479 method: str,480 url: typing.Union[str, URL],481 *,482 data: RequestData = b"",483- query_params: QueryParamTypes = None,483+ params: QueryParamTypes = None,484 headers: HeaderTypes = None,485 cookies: CookieTypes = None,486 ):487 self.method = method.upper()488- self.url = URL(url, query_params=query_params)488+ self.url = URL(url, params=params)489 self.headers = Headers(headers)490 if cookies:491 self._cookies = Cookies(cookies)492 self._cookies.set_cookie_header(self)487 unmodified lines980 assert domain is not None981 args.append(path)982 self.jar.clear(*args)983 984- def update(self, cookies: CookieTypes) -> None: # type: ignore984+ def update(self, cookies: CookieTypes = None) -> None: # type: ignore985 cookies = Cookies(cookies)986 for cookie in cookies.jar:987 self.jar.set_cookie(cookie)988 55 unmodified linesmodified:tests/models/test_url.py+3 added-3 removed
23 unmodified lines24 assert new == URL("http://example.org:123/path/to/somewhere?abc=123#anchor")25 assert new.scheme == "http"26 27 28-def test_url_query_params():29- url = URL("https://example.org:123/path/to/somewhere", query_params={"a": "123"})28+def test_url__params():29+ url = URL("https://example.org:123/path/to/somewhere", params={"a": "123"})30 assert str(url) == "https://example.org:123/path/to/somewhere?a=123"31 32 url = URL(33- "https://example.org:123/path/to/somewhere?b=456", query_params={"a": "123"}33+ "https://example.org:123/path/to/somewhere?b=456", params={"a": "123"}34 )35 assert str(url) == "https://example.org:123/path/to/somewhere?a=123"36 37 9 unmodified linesmodified:README.md+10 added-10 removed
96 unmodified lines97 >>> response = client.get('https://example.org')98 ```99 100 * `def __init__([ssl], [timeout], [pool_limits], [max_redirects], [dispatch])`101-* `def .request(method, url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102-* `def .get(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103-* `def .options(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104-* `def .head(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105-* `def .post(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106-* `def .put(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107-* `def .patch(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`108-* `def .delete(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`101+* `def .request(method, url, [content], [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102+* `def .get(url, [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103+* `def .options(url, [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104+* `def .head(url, [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105+* `def .post(url, [content], [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106+* `def .put(url, [content], [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107+* `def .patch(url, [content], [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`108+* `def .delete(url, [content], [params], [headers], [stream], [allow_redirects], [ssl], [timeout])`109 * `def .prepare_request(request)`110 * `def .send(request, [stream], [allow_redirects], [ssl], [timeout])`111 * `def .close()`112 31 unmodified lines144 >>> request = Request("GET", "https://example.org", headers={'host': 'example.org'})145 >>> response = client.send(request)146 ```147 148-* `def __init__(method, url, query_params, content, headers)`148+* `def __init__(method, url, params, content, headers)`149 * `.method` - **str** (Uppercased)150 * `.url` - **URL**151 * `.content` - **byte** or **byte async iterator**152 * `.headers` - **Headers**7 unmodified lines160 >>> url.host161 'example.org'162 ```163 164-* `def __init__(url, allow_relative=False, query_params=None)`164+* `def __init__(url, allow_relative=False, params=None)`165 * `.scheme` - **str**166 * `.authority` - **str**167 * `.host` - **str**168 * `.port` - **int**62 unmodified lines