Skip to content
Myr

Pre commit update (#6498)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by GitHub · parent 2c193bd · Browse files · 7 files+9 added−29 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+9 added−29 removed

  • tests:+0 added−13 removed
  • other:+9 added−16 removed

7 files+9 added−29 removed

modified:requests/adapters.py-1 removed
245 unmodified lines
246 to a CA bundle to use247 :param cert: The SSL certificate to verify.248 """249 if url.lower().startswith("https") and verify:250250 cert_loc = None251252 # Allow self-specified cert location.253 if verify is not True:
284 unmodified lines
modified:requests/auth.py-1 removed
256 unmodified lines
257 r.request.body.seek(self._thread_local.pos)258 s_auth = r.headers.get("www-authenticate", "")259260 if "digest" in s_auth.lower() and self._thread_local.num_401_calls < 2:261261 self._thread_local.num_401_calls += 1262 pat = re.compile(r"digest ", flags=re.IGNORECASE)263 self._thread_local.chal = parse_dict_header(pat.sub("", s_auth, count=1))264
50 unmodified lines
modified:requests/models.py+2 added-4 removed
168 unmodified lines
169 v.encode("utf-8") if isinstance(v, str) else v,170 )171 )172173 for (k, v) in files:173 for k, v in files:174 # support for explicit filename175 ft = None176 fh = None177 if isinstance(v, (tuple, list)):
89 unmodified lines
267 cookies=None,268 hooks=None,269 json=None,270 ):271271 # Default empty dicts for dict params.272 data = [] if data is None else data273 files = [] if files is None else files274 headers = {} if headers is None else headers275 params = {} if params is None else params276 hooks = {} if hooks is None else hooks277278 self.hooks = default_hooks()280 for (k, v) in list(hooks.items()):279 for k, v in list(hooks.items()):280 self.register_hook(event=k, hook=v)281282 self.method = method283 self.url = url
579 unmodified lines
863864 for chunk in self.iter_content(865 chunk_size=chunk_size, decode_unicode=decode_unicode866 ):868867 if pending is not None:868 chunk = pending + chunk869870 if delimiter:
162 unmodified lines
modified:requests/sessions.py+2 added-6 removed
260 unmodified lines
261262 if yield_requests:263 yield req264 else:265265 resp = self.send(266 req,267 stream=stream,268 timeout=timeout,
118 unmodified lines
387 "max_redirects",388 ]389390 def __init__(self):392391 #: A case-insensitive dictionary of headers to be sent on each392 #: :class:`Request <Request>` sent from this393 #: :class:`Session <Session>`.394 self.headers = default_headers()
315 unmodified lines
710 r = dispatch_hook("response", hooks, r, **kwargs)711712 # Persist cookies713 if r.history:716714 # If the hooks create history then we want those cookies too715 for resp in r.history:716 extract_cookies_to_jar(self.cookies, resp.request, resp.raw)717
39 unmodified lines
757 if self.trust_env:758 # Set environment's proxies.759 no_proxy = proxies.get("no_proxy") if proxies is not None else None760 env_proxies = get_environ_proxies(url, no_proxy=no_proxy)764 for (k, v) in env_proxies.items():761 for k, v in env_proxies.items():762 proxies.setdefault(k, v)763764 # Look for requests environment configuration765 # and be compatible with cURL.
17 unmodified lines
783 Returns the appropriate connection adapter for the given URL.784785 :rtype: requests.adapters.BaseAdapter786 """790 for (prefix, adapter) in self.adapters.items():791787 for prefix, adapter in self.adapters.items():788 if url.lower().startswith(prefix.lower()):789 return adapter790791 # Nothing matches :-/
40 unmodified lines
modified:requests/utils.py+1 added
761 unmodified lines
762 Returns whether we should bypass proxies or not.763764 :rtype: bool765 """766767 # Prioritize lowercase environment variables over uppercase768 # to keep a consistent behaviour with other http projects (curl, wget).769 def get_proxy(key):770 return os.environ.get(key) or os.environ.get(key.upper())
321 unmodified lines
modified:tests/test_requests.py-13 removed
73 unmodified lines
74 HAS_PYOPENSSL = False757677class TestRequests:7878 digest_auth_algo = ("MD5", "SHA-256", "SHA-512")7980 def test_entry_points(self):8281 requests.session82 requests.session().get83 requests.session().head84 requests.get
422 unmodified lines
507 assert items[5] == ("Fifth", "5")508509 @pytest.mark.parametrize("key", ("User-agent", "user-agent"))510 def test_user_agent_transfers(self, httpbin, key):513511 heads = {key: "Mozilla/5.0 (github.com/psf/requests)"}512513 r = requests.get(httpbin("user-agent"), headers=heads)514 assert heads[key] in r.text
185 unmodified lines
700 finally:701 requests.sessions.get_netrc_auth = old_auth702703 def test_DIGEST_HTTP_200_OK_GET(self, httpbin):707704 for authtype in self.digest_auth_algo:705 auth = HTTPDigestAuth("user", "pass")706 url = httpbin("digest-auth", "auth", "user", "pass", authtype, "never")707
9 unmodified lines
717 r = s.get(url)718 assert r.status_code == 200719720 def test_DIGEST_AUTH_RETURNS_COOKIE(self, httpbin):725721 for authtype in self.digest_auth_algo:722 url = httpbin("digest-auth", "auth", "user", "pass", authtype)723 auth = HTTPDigestAuth("user", "pass")724 r = requests.get(url)
2 unmodified lines
727 r = requests.get(url, auth=auth)728 assert r.status_code == 200729730 def test_DIGEST_AUTH_SETS_SESSION_COOKIES(self, httpbin):736731 for authtype in self.digest_auth_algo:732 url = httpbin("digest-auth", "auth", "user", "pass", authtype)733 auth = HTTPDigestAuth("user", "pass")734 s = requests.Session()735 s.get(url, auth=auth)736 assert s.cookies["fake"] == "fake_value"737738 def test_DIGEST_STREAM(self, httpbin):745739 for authtype in self.digest_auth_algo:740 auth = HTTPDigestAuth("user", "pass")741 url = httpbin("digest-auth", "auth", "user", "pass", authtype)742
3 unmodified lines
746 r = requests.get(url, auth=auth, stream=False)747 assert r.raw.read() == b""748749 def test_DIGESTAUTH_WRONG_HTTP_401_GET(self, httpbin):757750 for authtype in self.digest_auth_algo:751 auth = HTTPDigestAuth("user", "wrongpass")752 url = httpbin("digest-auth", "auth", "user", "pass", authtype)753
8 unmodified lines
762 r = s.get(url)763 assert r.status_code == 401764765 def test_DIGESTAUTH_QUOTES_QOP_VALUE(self, httpbin):774766 for authtype in self.digest_auth_algo:767 auth = HTTPDigestAuth("user", "pass")768 url = httpbin("digest-auth", "auth", "user", "pass", authtype)769770 r = requests.get(url, auth=auth)771 assert '"auth"' in r.request.headers["Authorization"]772773 def test_POSTBIN_GET_POST_FILES(self, httpbin):783774 url = httpbin("post")775 requests.post(url).raise_for_status()776777 post1 = requests.post(url, data={"some": "data"})
9 unmodified lines
787 with pytest.raises(ValueError):788 requests.post(url, files=["bad file data"])789790 def test_invalid_files_input(self, httpbin):801791 url = httpbin("post")792 post = requests.post(url, files={"random-file-1": None, "random-file-2": 1})793 assert b'name="random-file-1"' not in post.request.body794 assert b'name="random-file-2"' in post.request.body
39 unmodified lines
834 assert post2.status_code == 200835 assert post2.json()["data"] == "st"836837 def test_POSTBIN_GET_POST_FILES_WITH_DATA(self, httpbin):849838 url = httpbin("post")839 requests.post(url).raise_for_status()840841 post1 = requests.post(url, data={"some": "data"})
180 unmodified lines
1022 # fail if we use our default trust bundle.1023 requests.get(httpbin_secure("status", "200"))10241025 def test_urlencoded_get_query_multivalued_param(self, httpbin):10381026 r = requests.get(httpbin("get"), params={"test": ["foo", "baz"]})1027 assert r.status_code == 2001028 assert r.url == httpbin("get?test=foo&test=baz")1029
1769 unmodified lines
modified:.pre-commit-config.yaml+4 added-4 removed