__init__.py

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-03-15 16:47:02 -04:00
parent f132bfbc6a
commit e407afc494
3 changed files with 13 additions and 11 deletions
+11 -9
View File
@@ -45,23 +45,23 @@ from .exceptions import RequestsDependencyWarning
def check_compatibility(urllib3_version: str, chardet_version: str) -> None:
urllib3_version = urllib3_version.split('.')
urllib3_version = urllib3_version.split('.') # type: ignore
assert urllib3_version != [
'dev'
] # Verify urllib3 isn't installed from git.
# Sometimes, urllib3 only reports its version as 16.1.
if len(urllib3_version) == 2:
urllib3_version.append('0')
urllib3_version.append('0') # type: ignore
# Check urllib3 for compatibility.
major, minor, patch = urllib3_version # noqa: F811
major, minor, patch = int(major), int(minor), int(patch)
major, minor, patch = int(major), int(minor), int(patch) # type: ignore
# urllib3 >= 1.21.1, <= 1.22
assert major == 1
assert minor >= 21
assert minor <= 22
assert major == 1 # type: ignore
assert minor >= 21 # type: ignore
assert minor <= 22 # type: ignore
# Check chardet for compatibility.
major, minor, patch = chardet_version.split('.')[:3]
major, minor, patch = int(major), int(minor), int(patch)
major, minor, patch = int(major), int(minor), int(patch) # type: ignore
# chardet >= 3.0.2, < 3.1.0
assert major == 3 # type: ignore
assert minor < 1 # type: ignore
@@ -71,11 +71,13 @@ def check_compatibility(urllib3_version: str, chardet_version: str) -> None:
def _check_cryptography(cryptography_version: str) -> None:
# cryptography < 1.3.4
try:
cryptography_version = list(map(int, cryptography_version.split('.')))
cryptography_version = list(
map(int, cryptography_version.split('.'))
) # type: ignore
except ValueError:
return
if cryptography_version < [1, 3, 4]:
if cryptography_version < [1, 3, 4]: # type: ignore
warning = 'Old version of cryptography ({0}) may cause slowdown.'.format(
cryptography_version
)
+1 -1
View File
@@ -96,7 +96,7 @@ class HTTPHeaderDict(CaseInsensitiveDict):
self.extend({} if data is None else data, **kwargs)
#
#
# We'll store tuples in the internal dictionary, but present them as a
# concatenated string when we use item access methods.
#
+1 -1
View File
@@ -180,7 +180,7 @@ def get_netrc_auth(
netrc_path = None
for f in NETRC_FILES:
try:
loc = os.path.expanduser('~/{0}'.format(f))
loc = os.path.expanduser(f'~/{f}')
except KeyError:
# os.path.expanduser can fail when $HOME is undefined and
# getpwuid fails. See http://bugs.python.org/issue20164 &