diff --git a/httpie/client.py b/httpie/client.py index 59bd9bee..054783f9 100644 --- a/httpie/client.py +++ b/httpie/client.py @@ -1,6 +1,5 @@ import json import sys -from pprint import pformat import requests from requests.adapters import HTTPAdapter diff --git a/httpie/compat.py b/httpie/compat.py index 2e9e3291..d626e984 100644 --- a/httpie/compat.py +++ b/httpie/compat.py @@ -14,10 +14,14 @@ is_windows = 'win32' in str(sys.platform).lower() if is_py2: + # noinspection PyShadowingBuiltins bytes = str + # noinspection PyUnresolvedReferences,PyShadowingBuiltins str = unicode elif is_py3: + # noinspection PyShadowingBuiltins str = str + # noinspection PyShadowingBuiltins bytes = bytes @@ -32,7 +36,7 @@ try: # pragma: no cover # noinspection PyCompatibility from urllib.request import urlopen except ImportError: # pragma: no cover - # noinspection PyCompatibility + # noinspection PyCompatibility,PyUnresolvedReferences from urllib2 import urlopen try: # pragma: no cover @@ -40,10 +44,10 @@ try: # pragma: no cover except ImportError: # pragma: no cover # Python 2.6 OrderedDict class, needed for headers, parameters, etc .### # - # noinspection PyCompatibility + # noinspection PyCompatibility,PyUnresolvedReferences from UserDict import DictMixin - # noinspection PyShadowingBuiltins + # noinspection PyShadowingBuiltins,PyCompatibility class OrderedDict(dict, DictMixin): # Copyright (c) 2009 Raymond Hettinger # @@ -115,6 +119,7 @@ except ImportError: # pragma: no cover if not self: raise KeyError('dictionary is empty') if last: + # noinspection PyUnresolvedReferences key = reversed(self).next() else: key = iter(self).next() diff --git a/httpie/downloads.py b/httpie/downloads.py index 58e7b943..5c19beae 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -78,15 +78,15 @@ def parse_content_range(content_range, resumed_from): # last-byte-pos value, is invalid. The recipient of an invalid # byte-content-range- spec MUST ignore it and any content # transferred along with it." - if (first_byte_pos >= last_byte_pos - or (instance_length is not None - and instance_length <= last_byte_pos)): + if (first_byte_pos >= last_byte_pos or + (instance_length is not None and + instance_length <= last_byte_pos)): raise ContentRangeError( 'Invalid Content-Range returned: %r' % content_range) - if (first_byte_pos != resumed_from - or (instance_length is not None - and last_byte_pos + 1 != instance_length)): + if (first_byte_pos != resumed_from or + (instance_length is not None and + last_byte_pos + 1 != instance_length)): # Not what we asked for. raise ContentRangeError( 'Unexpected Content-Range returned (%r)' @@ -308,9 +308,9 @@ class Downloader(object): @property def interrupted(self): return ( - self.finished - and self.status.total_size - and self.status.total_size != self.status.downloaded + self.finished and + self.status.total_size and + self.status.total_size != self.status.downloaded ) def chunk_downloaded(self, chunk): @@ -399,8 +399,8 @@ class ProgressReporterThread(threading.Thread): if now - self._prev_time >= self._update_interval: downloaded = self.status.downloaded try: - speed = ((downloaded - self._prev_bytes) - / (now - self._prev_time)) + speed = ((downloaded - self._prev_bytes) / + (now - self._prev_time)) except ZeroDivisionError: speed = 0 @@ -434,11 +434,11 @@ class ProgressReporterThread(threading.Thread): self._prev_bytes = downloaded self.output.write( - CLEAR_LINE - + ' ' - + SPINNER[self._spinner_pos] - + ' ' - + self._status_line + CLEAR_LINE + + ' ' + + SPINNER[self._spinner_pos] + + ' ' + + self._status_line ) self.output.flush() @@ -447,8 +447,8 @@ class ProgressReporterThread(threading.Thread): else 0) def sum_up(self): - actually_downloaded = (self.status.downloaded - - self.status.resumed_from) + actually_downloaded = ( + self.status.downloaded - self.status.resumed_from) time_taken = self.status.time_finished - self.status.time_started self.output.write(CLEAR_LINE) @@ -463,8 +463,8 @@ class ProgressReporterThread(threading.Thread): self.output.write(SUMMARY.format( downloaded=humanize_bytes(actually_downloaded), - total=(self.status.total_size - and humanize_bytes(self.status.total_size)), + total=(self.status.total_size and + humanize_bytes(self.status.total_size)), speed=humanize_bytes(speed), time=time_taken, )) diff --git a/httpie/input.py b/httpie/input.py index 0c8a0cef..99a4849c 100644 --- a/httpie/input.py +++ b/httpie/input.py @@ -309,9 +309,10 @@ class HTTPieArgumentParser(ArgumentParser): self.args.url = self.args.method # Infer the method has_data = ( - (not self.args.ignore_stdin and not self.env.stdin_isatty) - or any(item.sep in SEP_GROUP_DATA_ITEMS - for item in self.args.items) + (not self.args.ignore_stdin and + not self.env.stdin_isatty) or + any(item.sep in SEP_GROUP_DATA_ITEMS + for item in self.args.items) ) self.args.method = HTTP_POST if has_data else HTTP_GET @@ -439,8 +440,8 @@ class SessionNameValidator(object): def __call__(self, value): # Session name can be a path or just a name. - if (os.path.sep not in value - and not VALID_SESSION_NAME_PATTERN.search(value)): + if (os.path.sep not in value and + not VALID_SESSION_NAME_PATTERN.search(value)): raise ArgumentError(None, self.error_message) return value diff --git a/httpie/plugins/builtin.py b/httpie/plugins/builtin.py index 0f1a806b..0e3aa26d 100644 --- a/httpie/plugins/builtin.py +++ b/httpie/plugins/builtin.py @@ -5,6 +5,7 @@ import requests.auth from httpie.plugins.base import AuthPlugin +# noinspection PyAbstractClass class BuiltinAuthPlugin(AuthPlugin): package_name = '(builtin)'