Skip to content

Commit

Permalink
pylint: Ignore false-negatives for unsubscriptable values
Browse files Browse the repository at this point in the history
The latest pylint is more picky about E1136 and produces couple of
false-negatives. Some are handled by code (check if is None), some
are caused by urlparse, which on latest versions returns custom object
instead of tuple. Anyway the ParseResult can be accessed via indexes
as in the old version (python-2.7.10-8.fc23.x86_64)

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
  • Loading branch information
ldoktor committed Nov 30, 2015
1 parent aa7c496 commit 980f2f9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/shared/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ def _format_mock_failure_message(self, args, kwargs):
expected_string = self._format_mock_call_signature(args, kwargs)
call_args = self.call_args
if len(call_args) == 3:
call_args = call_args[1:]
# Can't get here when selc.call_args is None, ignore E1136
call_args = call_args[1:] # pylint: disable=E1136
actual_string = self._format_mock_call_signature(*call_args)
return message % (expected_string, actual_string)

Expand Down
3 changes: 2 additions & 1 deletion client/shared/test_utils/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def __method_playback(self, symbol, *args, **dargs):
_dump_function_call(symbol, args, dargs))

if len(self.recording) != 0:
func_call = self.recording[0]
# self.recording is subscriptable (deque), ignore E1136
func_call = self.recording[0] # pylint: disable=E1136
if func_call.symbol != symbol:
msg = ("Unexpected call: %s\nExpected: %s"
% (_dump_function_call(symbol, args, dargs),
Expand Down
5 changes: 3 additions & 2 deletions client/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def is_url(path):
"""Return true if path looks like a URL"""
# for now, just handle http and ftp
url_parts = urlparse.urlparse(path)
return (url_parts[0] in ('http', 'ftp', 'git'))
return (url_parts[0] in ('http', 'ftp', 'git')) # pylint: disable=E1136


def urlopen(url, data=None, timeout=5):
Expand Down Expand Up @@ -797,7 +797,8 @@ def unmap_url(srcdir, src, destdir='.'):
"""
if is_url(src):
url_parts = urlparse.urlparse(src)
filename = os.path.basename(url_parts[2])
# ParseResult is subscriptable, ignore E1136
filename = os.path.basename(url_parts[2]) # pylint: disable=E1136
dest = os.path.join(destdir, filename)
return get_file(src, dest)
else:
Expand Down
6 changes: 4 additions & 2 deletions frontend/shared/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@


def _get_request_headers(uri):
server = urlparse.urlparse(uri)[0:2]
# ParseResult is subscriptable, ignore E1136
server = urlparse.urlparse(uri)[0:2] # pylint: disable=E1136
if server in _request_headers:
return _request_headers[server]

Expand All @@ -26,7 +27,8 @@ def _get_request_headers(uri):


def _clear_request_headers(uri):
server = urlparse.urlparse(uri)[0:2]
# ParseResult is subscriptable, ignore E1136
server = urlparse.urlparse(uri)[0:2] # pylint: disable=E1136
if server in _request_headers:
del _request_headers[server]

Expand Down

0 comments on commit 980f2f9

Please sign in to comment.