offlineimap/folder files singleton-comparison

This patch change these errors in the 'folder' folder

C0121: Comparison to None should be 'expr is None' (singleton-comparison)
C0121: Comparison to None should be 'expr is not None' (singleton-comparison)
This commit is contained in:
Rodolfo García Peñas (kix) 2020-08-30 11:15:00 +02:00
parent 229aa59dba
commit 7b082f0fe9
4 changed files with 11 additions and 11 deletions

View File

@ -223,7 +223,7 @@ class BaseFolder():
:returns: Boolean indicating the match. Returns True in case it :returns: Boolean indicating the match. Returns True in case it
implicitely saved the UIDVALIDITY.""" implicitely saved the UIDVALIDITY."""
if self.get_saveduidvalidity() != None: if self.get_saveduidvalidity() is not None:
return self.get_saveduidvalidity() == self.get_uidvalidity() return self.get_saveduidvalidity() == self.get_uidvalidity()
else: else:
self.save_uidvalidity() self.save_uidvalidity()
@ -939,7 +939,7 @@ class BaseFolder():
# Execute new mail hook if we have new mail. # Execute new mail hook if we have new mail.
if self.have_newmail: if self.have_newmail:
if self.newmail_hook != None: if self.newmail_hook is not None:
self.newmail_hook() self.newmail_hook()
def __syncmessagesto_delete(self, dstfolder, statusfolder): def __syncmessagesto_delete(self, dstfolder, statusfolder):

View File

@ -148,7 +148,7 @@ class GmailFolder(IMAPFolder):
for messagestr in response: for messagestr in response:
# looks like: '1 (FLAGS (\\Seen Old) X-GM-LABELS (\\Inbox \\Favorites) UID 4807)' or None if no msg # looks like: '1 (FLAGS (\\Seen Old) X-GM-LABELS (\\Inbox \\Favorites) UID 4807)' or None if no msg
# Discard initial message number. # Discard initial message number.
if messagestr == None: if messagestr is None:
continue continue
messagestr = messagestr.split(' ', 1)[1] messagestr = messagestr.split(' ', 1)[1]
# e.g.: {'X-GM-LABELS': '("Webserver (RW.net)" "\\Inbox" GInbox)', 'FLAGS': '(\\Seen)', 'UID': '275440'} # e.g.: {'X-GM-LABELS': '("Webserver (RW.net)" "\\Inbox" GInbox)', 'FLAGS': '(\\Seen)', 'UID': '275440'}

View File

@ -140,7 +140,7 @@ class IMAPFolder(BaseFolder):
# SELECT (if not already done) and get current UIDVALIDITY. # SELECT (if not already done) and get current UIDVALIDITY.
self.__selectro(imapobj) self.__selectro(imapobj)
typ, uidval = imapobj.response('UIDVALIDITY') typ, uidval = imapobj.response('UIDVALIDITY')
assert uidval != [None] and uidval != None, \ assert uidval != [None] and uidval is not None, \
"response('UIDVALIDITY') returned [None]!" "response('UIDVALIDITY') returned [None]!"
self._uidvalidity = int(uidval[-1]) self._uidvalidity = int(uidval[-1])
return self._uidvalidity return self._uidvalidity
@ -237,16 +237,16 @@ class IMAPFolder(BaseFolder):
conditions = [] conditions = []
# 1. min_uid condition. # 1. min_uid condition.
if min_uid != None: if min_uid is not None:
conditions.append("UID %d:*" % min_uid) conditions.append("UID %d:*" % min_uid)
# 2. date condition. # 2. date condition.
elif min_date != None: elif min_date is not None:
# Find out what the oldest message is that we should look at. # Find out what the oldest message is that we should look at.
conditions.append("SINCE %02d-%s-%d" % ( conditions.append("SINCE %02d-%s-%d" % (
min_date[2], MonthNames[min_date[1]], min_date[0])) min_date[2], MonthNames[min_date[1]], min_date[0]))
# 3. maxsize condition. # 3. maxsize condition.
maxsize = self.getmaxsize() maxsize = self.getmaxsize()
if maxsize != None: if maxsize is not None:
conditions.append("SMALLER %d" % maxsize) conditions.append("SMALLER %d" % maxsize)
if len(conditions) >= 1: if len(conditions) >= 1:
@ -535,7 +535,7 @@ class IMAPFolder(BaseFolder):
if rtime is None: if rtime is None:
rtime = emailutil.get_message_date(content) rtime = emailutil.get_message_date(content)
if rtime == None: if rtime is None:
return None return None
datetuple = time.localtime(rtime) datetuple = time.localtime(rtime)

View File

@ -199,9 +199,9 @@ class MaildirFolder(BaseFolder):
nouidcounter -= 1 nouidcounter -= 1
else: else:
uid = int(uidmatch.group(1)) uid = int(uidmatch.group(1))
if min_uid != None and uid > 0 and uid < min_uid: if min_uid is not None and uid > 0 and uid < min_uid:
continue continue
if min_date != None and not self._iswithintime(filename, min_date): if min_date is not None and not self._iswithintime(filename, min_date):
# Keep track of messages outside of the time limit, because they # Keep track of messages outside of the time limit, because they
# still might have UID > min(UIDs of within-min_date). We hit # still might have UID > min(UIDs of within-min_date). We hit
# this case for maxage if any message had a known/valid datetime # this case for maxage if any message had a known/valid datetime
@ -218,7 +218,7 @@ class MaildirFolder(BaseFolder):
retval[uid] = self.msglist_item_initializer(uid) retval[uid] = self.msglist_item_initializer(uid)
retval[uid]['flags'] = flags retval[uid]['flags'] = flags
retval[uid]['filename'] = filepath retval[uid]['filename'] = filepath
if min_date != None: if min_date is not None:
# Re-include messages with high enough uid's. # Re-include messages with high enough uid's.
positive_uids = [uid for uid in retval if uid > 0] positive_uids = [uid for uid in retval if uid > 0]
if positive_uids: if positive_uids: