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

Commit 4435d84

Browse files
authored
Merge pull request #400 from cloudant/fix-pylint-2.1.1
Fix pylint warning messages
2 parents 9bd7718 + a01e95a commit 4435d84

File tree

9 files changed

+23
-27
lines changed

9 files changed

+23
-27
lines changed

pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ confidence=
6666
# Disable "redefined-variable-type" refactor warning messages
6767
# Disable "too-many-..." and "too-few-..." refactor warning messages
6868
# Disable "locally-disabled" message
69-
disable=R0204,R0901,R0902,R0903,R0904,R0913,R0914,R0915,locally-disabled,keyword-arg-before-vararg
69+
# Disable Python 3 "useless-object-inheritance" message
70+
disable=R0204,R0901,R0902,R0903,R0904,R0913,R0914,R0915,locally-disabled,keyword-arg-before-vararg,useless-object-inheritance
7071

7172

7273
[REPORTS]

src/cloudant/_common_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def feed_arg_types(feed_type):
147147
"""
148148
if feed_type == 'Cloudant':
149149
return _DB_UPDATES_ARG_TYPES
150-
elif feed_type == 'CouchDB':
150+
if feed_type == 'CouchDB':
151151
return _COUCH_DB_UPDATES_ARG_TYPES
152152
return _CHANGES_ARG_TYPES
153153

@@ -200,7 +200,7 @@ def _py_to_couch_translate(key, val):
200200
try:
201201
if key in ['keys', 'endkey_docid', 'startkey_docid', 'stale', 'update']:
202202
return {key: val}
203-
elif val is None:
203+
if val is None:
204204
return {key: None}
205205
arg_converter = TYPE_CONVERTERS.get(type(val))
206206
return {key: arg_converter(val)}

src/cloudant/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def __getitem__(self, key):
387387
db = self._DATABASE_CLASS(self, key)
388388
if db.exists():
389389
super(CouchDB, self).__setitem__(key, db)
390-
return db
391390
else:
392391
raise KeyError(key)
392+
return db
393393

394394
def __delitem__(self, key, remote=False):
395395
"""

src/cloudant/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def get_view_result(self, ddoc_id, view_name, raw_result=False, **kwargs):
337337
view = View(DesignDocument(self, ddoc_id), view_name)
338338
if raw_result:
339339
return view(**kwargs)
340-
elif kwargs:
340+
if kwargs:
341341
return Result(view, **kwargs)
342342

343343
return view.result
@@ -613,9 +613,9 @@ def __getitem__(self, key):
613613
if doc.exists():
614614
doc.fetch()
615615
super(CouchDatabase, self).__setitem__(key, doc)
616-
return doc
617616
else:
618617
raise KeyError(key)
618+
return doc
619619

620620
def __contains__(self, key):
621621
"""

src/cloudant/document.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def exists(self):
112112
"""
113113
if self._document_id is None:
114114
return False
115-
else:
116-
resp = self.r_session.head(self.document_url)
117-
if resp.status_code not in [200, 404]:
118-
resp.raise_for_status()
115+
116+
resp = self.r_session.head(self.document_url)
117+
if resp.status_code not in [200, 404]:
118+
resp.raise_for_status()
119119

120120
return resp.status_code == 200
121121

@@ -154,7 +154,6 @@ def create(self):
154154
self._document_id = data['id']
155155
super(Document, self).__setitem__('_id', data['id'])
156156
super(Document, self).__setitem__('_rev', data['rev'])
157-
return
158157

159158
def fetch(self):
160159
"""
@@ -320,7 +319,6 @@ def delete(self):
320319
del_resp.raise_for_status()
321320
self.clear()
322321
self.__setitem__('_id', self._document_id)
323-
return
324322

325323
def __enter__(self):
326324
"""
@@ -413,13 +411,13 @@ def get_attachment(
413411
attachment_type = 'binary'
414412

415413
if write_to is not None:
416-
if attachment_type == 'text' or attachment_type == 'json':
414+
if attachment_type in ('text', 'json'):
417415
write_to.write(resp.text)
418416
else:
419417
write_to.write(resp.content)
420418
if attachment_type == 'text':
421419
return resp.text
422-
elif attachment_type == 'json':
420+
if attachment_type == 'json':
423421
return resp.json()
424422

425423
return resp.content

src/cloudant/feed.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ def _process_data(self, line):
164164
skip = False
165165
if self._raw_data:
166166
return skip, line
167-
else:
168-
line = unicode_(line)
167+
line = unicode_(line)
169168
if not line:
170169
if (self._options.get('heartbeat', False) and
171170
self._options.get('feed') in ('continuous', 'longpoll') and

src/cloudant/index.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ def create(self):
145145
resp.raise_for_status()
146146
self._ddoc_id = resp.json()['id']
147147
self._name = resp.json()['name']
148-
return
149148

150149
def _def_check(self):
151150
"""
@@ -168,7 +167,6 @@ def delete(self):
168167
url = '/'.join((self.index_url, ddoc_id, self._type, self._name))
169168
resp = self._r_session.delete(url)
170169
resp.raise_for_status()
171-
return
172170

173171
class TextIndex(Index):
174172
"""

src/cloudant/result.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ def _handle_result_by_idx_slice(self, idx_slice):
268268
start = idx_slice.start
269269
stop = idx_slice.stop
270270
data = None
271-
if (start is not None and stop is not None and
272-
start >= 0 and stop >= 0 and start < stop):
271+
# start and stop cannot be None and both must be greater than 0
272+
if all(i is not None and i >= 0 for i in [start, stop]) and start < stop:
273273
if limit is not None:
274274
if start >= limit:
275275
# Result is out of range
276276
return dict()
277-
elif stop > limit:
277+
if stop > limit:
278278
# Ensure that slice does not extend past original limit
279279
return self._ref(skip=skip+start, limit=limit-start, **opts)
280280
data = self._ref(skip=skip+start, limit=stop-start, **opts)
@@ -498,8 +498,8 @@ def __getitem__(self, arg):
498498
type_or_none(int, arg.start) and
499499
type_or_none(int, arg.stop))):
500500
return super(QueryResult, self).__getitem__(arg)
501-
else:
502-
raise ResultException(101, arg)
501+
502+
raise ResultException(101, arg)
503503

504504
def _parse_data(self, data):
505505
"""

src/cloudant/scheduler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def list_docs(self, limit=None, skip=None):
4141
:param skip: How many result to skip starting at the beginning, if ordered by document ID.
4242
"""
4343
params = dict()
44-
if limit != None:
44+
if limit is not None:
4545
params["limit"] = limit
46-
if skip != None:
46+
if skip is not None:
4747
params["skip"] = skip
4848
resp = self._r_session.get('/'.join([self._scheduler, 'docs']), params=params)
4949
resp.raise_for_status()
@@ -72,9 +72,9 @@ def list_jobs(self, limit=None, skip=None):
7272
:param skip: How many result to skip starting at the beginning, if ordered by document ID.
7373
"""
7474
params = dict()
75-
if limit != None:
75+
if limit is not None:
7676
params["limit"] = limit
77-
if skip != None:
77+
if skip is not None:
7878
params["skip"] = skip
7979
resp = self._r_session.get('/'.join([self._scheduler, 'jobs']), params=params)
8080
resp.raise_for_status()

0 commit comments

Comments
 (0)