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
Provenance
- Commit
8112fcc- Tree
7f78907- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
2c193bd
7 files changed+9 added−29 removed
modified:requests/adapters.py-1 removed
245 unmodified lines246 to a CA bundle to use247 :param cert: The SSL certificate to verify.248 """249 if url.lower().startswith("https") and verify:250-250 cert_loc = None251 252 # Allow self-specified cert location.253 if verify is not True:284 unmodified linesmodified:requests/auth.py-1 removed
256 unmodified lines257 r.request.body.seek(self._thread_local.pos)258 s_auth = r.headers.get("www-authenticate", "")259 260 if "digest" in s_auth.lower() and self._thread_local.num_401_calls < 2:261-261 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 linesmodified:requests/models.py+2 added-4 removed
168 unmodified lines169 v.encode("utf-8") if isinstance(v, str) else v,170 )171 )172 173- 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 lines267 cookies=None,268 hooks=None,269 json=None,270 ):271-271 # 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 hooks277 278 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)281 282 self.method = method283 self.url = url579 unmodified lines863 864 for chunk in self.iter_content(865 chunk_size=chunk_size, decode_unicode=decode_unicode866 ):868-867 if pending is not None:868 chunk = pending + chunk869 870 if delimiter:162 unmodified linesmodified:requests/sessions.py+2 added-6 removed
260 unmodified lines261 262 if yield_requests:263 yield req264 else:265-265 resp = self.send(266 req,267 stream=stream,268 timeout=timeout,118 unmodified lines387 "max_redirects",388 ]389 390 def __init__(self):392-391 #: 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 lines710 r = dispatch_hook("response", hooks, r, **kwargs)711 712 # Persist cookies713 if r.history:716-714 # 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 lines757 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)763 764 # Look for requests environment configuration765 # and be compatible with cURL.17 unmodified lines783 Returns the appropriate connection adapter for the given URL.784 785 :rtype: requests.adapters.BaseAdapter786 """790- for (prefix, adapter) in self.adapters.items():791-787+ for prefix, adapter in self.adapters.items():788 if url.lower().startswith(prefix.lower()):789 return adapter790 791 # Nothing matches :-/40 unmodified linesmodified:requests/utils.py+1 added
761 unmodified lines762 Returns whether we should bypass proxies or not.763 764 :rtype: bool765 """766+767 # 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 linesmodified:tests/test_requests.py-13 removed
73 unmodified lines74 HAS_PYOPENSSL = False75 76 77 class TestRequests:78-78 digest_auth_algo = ("MD5", "SHA-256", "SHA-512")79 80 def test_entry_points(self):82-81 requests.session82 requests.session().get83 requests.session().head84 requests.get422 unmodified lines507 assert items[5] == ("Fifth", "5")508 509 @pytest.mark.parametrize("key", ("User-agent", "user-agent"))510 def test_user_agent_transfers(self, httpbin, key):513-511 heads = {key: "Mozilla/5.0 (github.com/psf/requests)"}512 513 r = requests.get(httpbin("user-agent"), headers=heads)514 assert heads[key] in r.text185 unmodified lines700 finally:701 requests.sessions.get_netrc_auth = old_auth702 703 def test_DIGEST_HTTP_200_OK_GET(self, httpbin):707-704 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 lines717 r = s.get(url)718 assert r.status_code == 200719 720 def test_DIGEST_AUTH_RETURNS_COOKIE(self, httpbin):725-721 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 lines727 r = requests.get(url, auth=auth)728 assert r.status_code == 200729 730 def test_DIGEST_AUTH_SETS_SESSION_COOKIES(self, httpbin):736-731 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"737 738 def test_DIGEST_STREAM(self, httpbin):745-739 for authtype in self.digest_auth_algo:740 auth = HTTPDigestAuth("user", "pass")741 url = httpbin("digest-auth", "auth", "user", "pass", authtype)742 3 unmodified lines746 r = requests.get(url, auth=auth, stream=False)747 assert r.raw.read() == b""748 749 def test_DIGESTAUTH_WRONG_HTTP_401_GET(self, httpbin):757-750 for authtype in self.digest_auth_algo:751 auth = HTTPDigestAuth("user", "wrongpass")752 url = httpbin("digest-auth", "auth", "user", "pass", authtype)753 8 unmodified lines762 r = s.get(url)763 assert r.status_code == 401764 765 def test_DIGESTAUTH_QUOTES_QOP_VALUE(self, httpbin):774-766 for authtype in self.digest_auth_algo:767 auth = HTTPDigestAuth("user", "pass")768 url = httpbin("digest-auth", "auth", "user", "pass", authtype)769 770 r = requests.get(url, auth=auth)771 assert '"auth"' in r.request.headers["Authorization"]772 773 def test_POSTBIN_GET_POST_FILES(self, httpbin):783-774 url = httpbin("post")775 requests.post(url).raise_for_status()776 777 post1 = requests.post(url, data={"some": "data"})9 unmodified lines787 with pytest.raises(ValueError):788 requests.post(url, files=["bad file data"])789 790 def test_invalid_files_input(self, httpbin):801-791 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.body39 unmodified lines834 assert post2.status_code == 200835 assert post2.json()["data"] == "st"836 837 def test_POSTBIN_GET_POST_FILES_WITH_DATA(self, httpbin):849-838 url = httpbin("post")839 requests.post(url).raise_for_status()840 841 post1 = requests.post(url, data={"some": "data"})180 unmodified lines1022 # fail if we use our default trust bundle.1023 requests.get(httpbin_secure("status", "200"))1024 1025 def test_urlencoded_get_query_multivalued_param(self, httpbin):1038-1026 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 linesmodified:.pre-commit-config.yaml+4 added-4 removed
12345567892 unmodified lines1213141516161718192021212223242526262728exclude: 'docs/|ext/'
repos:- repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 rev: v4.4.0 hooks: - id: check-yaml - id: debug-statements - id: end-of-file-fixer2 unmodified lines rev: 5.12.0 hooks: - id: isort- repo: https://github.com/psf/black rev: 22.3.0 rev: 23.7.0 hooks: - id: black exclude: tests/test_lowlevel.py- repo: https://github.com/asottile/pyupgrade rev: v2.31.1 rev: v3.10.1 hooks: - id: pyupgrade args: [--py37-plus]- repo: https://github.com/PyCQA/flake8 rev: 6.0.0 rev: 6.1.0 hooks: - id: flake8