Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Fixed pylint error messages
Browse files Browse the repository at this point in the history
- useless-object-inheritance warning message added to the disable list in pylintrc
  • Loading branch information
emlaver committed Aug 15, 2018
1 parent 9bd7718 commit a01e95a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ confidence=
# Disable "redefined-variable-type" refactor warning messages
# Disable "too-many-..." and "too-few-..." refactor warning messages
# Disable "locally-disabled" message
disable=R0204,R0901,R0902,R0903,R0904,R0913,R0914,R0915,locally-disabled,keyword-arg-before-vararg
# Disable Python 3 "useless-object-inheritance" message
disable=R0204,R0901,R0902,R0903,R0904,R0913,R0914,R0915,locally-disabled,keyword-arg-before-vararg,useless-object-inheritance


[REPORTS]
Expand Down
4 changes: 2 additions & 2 deletions src/cloudant/_common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def feed_arg_types(feed_type):
"""
if feed_type == 'Cloudant':
return _DB_UPDATES_ARG_TYPES
elif feed_type == 'CouchDB':
if feed_type == 'CouchDB':
return _COUCH_DB_UPDATES_ARG_TYPES
return _CHANGES_ARG_TYPES

Expand Down Expand Up @@ -200,7 +200,7 @@ def _py_to_couch_translate(key, val):
try:
if key in ['keys', 'endkey_docid', 'startkey_docid', 'stale', 'update']:
return {key: val}
elif val is None:
if val is None:
return {key: None}
arg_converter = TYPE_CONVERTERS.get(type(val))
return {key: arg_converter(val)}
Expand Down
2 changes: 1 addition & 1 deletion src/cloudant/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ def __getitem__(self, key):
db = self._DATABASE_CLASS(self, key)
if db.exists():
super(CouchDB, self).__setitem__(key, db)
return db
else:
raise KeyError(key)
return db

def __delitem__(self, key, remote=False):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/cloudant/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def get_view_result(self, ddoc_id, view_name, raw_result=False, **kwargs):
view = View(DesignDocument(self, ddoc_id), view_name)
if raw_result:
return view(**kwargs)
elif kwargs:
if kwargs:
return Result(view, **kwargs)

return view.result
Expand Down Expand Up @@ -613,9 +613,9 @@ def __getitem__(self, key):
if doc.exists():
doc.fetch()
super(CouchDatabase, self).__setitem__(key, doc)
return doc
else:
raise KeyError(key)
return doc

def __contains__(self, key):
"""
Expand Down
14 changes: 6 additions & 8 deletions src/cloudant/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def exists(self):
"""
if self._document_id is None:
return False
else:
resp = self.r_session.head(self.document_url)
if resp.status_code not in [200, 404]:
resp.raise_for_status()

resp = self.r_session.head(self.document_url)
if resp.status_code not in [200, 404]:
resp.raise_for_status()

return resp.status_code == 200

Expand Down Expand Up @@ -154,7 +154,6 @@ def create(self):
self._document_id = data['id']
super(Document, self).__setitem__('_id', data['id'])
super(Document, self).__setitem__('_rev', data['rev'])
return

def fetch(self):
"""
Expand Down Expand Up @@ -320,7 +319,6 @@ def delete(self):
del_resp.raise_for_status()
self.clear()
self.__setitem__('_id', self._document_id)
return

def __enter__(self):
"""
Expand Down Expand Up @@ -413,13 +411,13 @@ def get_attachment(
attachment_type = 'binary'

if write_to is not None:
if attachment_type == 'text' or attachment_type == 'json':
if attachment_type in ('text', 'json'):
write_to.write(resp.text)
else:
write_to.write(resp.content)
if attachment_type == 'text':
return resp.text
elif attachment_type == 'json':
if attachment_type == 'json':
return resp.json()

return resp.content
Expand Down
3 changes: 1 addition & 2 deletions src/cloudant/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ def _process_data(self, line):
skip = False
if self._raw_data:
return skip, line
else:
line = unicode_(line)
line = unicode_(line)
if not line:
if (self._options.get('heartbeat', False) and
self._options.get('feed') in ('continuous', 'longpoll') and
Expand Down
2 changes: 0 additions & 2 deletions src/cloudant/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def create(self):
resp.raise_for_status()
self._ddoc_id = resp.json()['id']
self._name = resp.json()['name']
return

def _def_check(self):
"""
Expand All @@ -168,7 +167,6 @@ def delete(self):
url = '/'.join((self.index_url, ddoc_id, self._type, self._name))
resp = self._r_session.delete(url)
resp.raise_for_status()
return

class TextIndex(Index):
"""
Expand Down
10 changes: 5 additions & 5 deletions src/cloudant/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ def _handle_result_by_idx_slice(self, idx_slice):
start = idx_slice.start
stop = idx_slice.stop
data = None
if (start is not None and stop is not None and
start >= 0 and stop >= 0 and start < stop):
# start and stop cannot be None and both must be greater than 0
if all(i is not None and i >= 0 for i in [start, stop]) and start < stop:
if limit is not None:
if start >= limit:
# Result is out of range
return dict()
elif stop > limit:
if stop > limit:
# Ensure that slice does not extend past original limit
return self._ref(skip=skip+start, limit=limit-start, **opts)
data = self._ref(skip=skip+start, limit=stop-start, **opts)
Expand Down Expand Up @@ -498,8 +498,8 @@ def __getitem__(self, arg):
type_or_none(int, arg.start) and
type_or_none(int, arg.stop))):
return super(QueryResult, self).__getitem__(arg)
else:
raise ResultException(101, arg)

raise ResultException(101, arg)

def _parse_data(self, data):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/cloudant/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def list_docs(self, limit=None, skip=None):
:param skip: How many result to skip starting at the beginning, if ordered by document ID.
"""
params = dict()
if limit != None:
if limit is not None:
params["limit"] = limit
if skip != None:
if skip is not None:
params["skip"] = skip
resp = self._r_session.get('/'.join([self._scheduler, 'docs']), params=params)
resp.raise_for_status()
Expand Down Expand Up @@ -72,9 +72,9 @@ def list_jobs(self, limit=None, skip=None):
:param skip: How many result to skip starting at the beginning, if ordered by document ID.
"""
params = dict()
if limit != None:
if limit is not None:
params["limit"] = limit
if skip != None:
if skip is not None:
params["skip"] = skip
resp = self._r_session.get('/'.join([self._scheduler, 'jobs']), params=params)
resp.raise_for_status()
Expand Down

0 comments on commit a01e95a

Please sign in to comment.