From e407afc49476e2f3dfb59f1476a09b2780837d75 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 15 Mar 2018 16:47:02 -0400 Subject: [PATCH] __init__.py Signed-off-by: Kenneth Reitz --- requests/__init__.py | 20 +++++++++++--------- requests/structures.py | 2 +- requests/utils.py | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/requests/__init__.py b/requests/__init__.py index b21f3908..39f39ced 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -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 ) diff --git a/requests/structures.py b/requests/structures.py index 0d78cb6b..f49ccdcf 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -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. # diff --git a/requests/utils.py b/requests/utils.py index e7189ef6..ba23612d 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -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 &