offlineimap/ files singleton-comparison

This patch change these errors in the offlineimap 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:27:03 +02:00
parent da2baaaeb7
commit 1a529b6b0e
5 changed files with 15 additions and 15 deletions

View File

@ -140,7 +140,7 @@ class CustomConfigParser(SafeConfigParser):
Returns transformed string."""
if string == None:
if string is None:
return None
for f in transforms:
string = f(string)

View File

@ -561,7 +561,7 @@ def syncfolder(account, remotefolder, quick):
new.cachemessagelist()
min_uid = partial.retrieve_min_uid()
if min_uid == None: # min_uid file didn't exist
if min_uid is None: # min_uid file didn't exist
if len(new.getmessageuidlist()) > 0:
raise OfflineImapError("To use startdate on Repository %s, "
"Repository %s must be empty" %
@ -612,27 +612,27 @@ def syncfolder(account, remotefolder, quick):
maxage = localfolder.getmaxage()
localstart = localfolder.getstartdate()
remotestart = remotefolder.getstartdate()
if (maxage != None) + (localstart != None) + (remotestart != None) > 1:
if (maxage is not None) + (localstart is not None) + (remotestart is not None) > 1:
six.reraise(OfflineImapError,
OfflineImapError("You can set at most one of the "
"following: maxage, startdate (for the local "
"folder), startdate (for the remote folder)",
OfflineImapError.ERROR.REPO),
exc_info()[2])
if (maxage != None or localstart or remotestart) and quick:
if (maxage is not None or localstart or remotestart) and quick:
# IMAP quickchanged isn't compatible with options that
# involve restricting the messagelist, since the "quick"
# check can only retrieve a full list of UIDs in the folder.
ui.warn("Quick syncs (-q) not supported in conjunction "
"with maxage or startdate; ignoring -q.")
if maxage != None:
if maxage is not None:
cachemessagelists_upto_date(maxage)
check_uid_validity()
elif localstart != None:
elif localstart is not None:
cachemessagelists_startdate(remotefolder, localfolder,
localstart)
check_uid_validity()
elif remotestart != None:
elif remotestart is not None:
cachemessagelists_startdate(localfolder, remotefolder,
remotestart)
check_uid_validity()

View File

@ -171,10 +171,10 @@ class IMAPServer():
def __getpassword(self):
"""Returns the server password or None"""
if self.goodpassword != None: # use cached good one first
if self.goodpassword is not None: # use cached good one first
return self.goodpassword
if self.password != None and self.passworderror == None:
if self.password is not None and self.passworderror is None:
return self.password # non-failed preconfigured one
# get 1) configured password first 2) fall back to asking via UI
@ -211,7 +211,7 @@ class IMAPServer():
passwd = self.__getpassword()
authz = ''
NULL = '\x00'
if self.user_identity != None:
if self.user_identity is not None:
authz = self.user_identity
retval = NULL.join((authz, authc, passwd))
@ -598,13 +598,13 @@ class IMAPServer():
if dat != [None]:
imapobj.capabilities = tuple(dat[-1].upper().split())
if self.delim == None:
if self.delim is None:
listres = imapobj.list(self.reference, '')[1]
if listres == [None] or listres == None:
if listres == [None] or listres is None:
# Some buggy IMAP servers do not respond well to LIST "" ""
# Work around them.
listres = imapobj.list(self.reference, '"*"')[1]
if listres == [None] or listres == None:
if listres == [None] or listres is None:
# No Folders were returned. This occurs, e.g. if the
# 'reference' prefix does not exist on the mail
# server. Raise exception.

View File

@ -208,7 +208,7 @@ def uid_sequence(uidlist):
for item in iter(sorted_uids):
item = int(item)
if start == None: # First item
if start is None: # First item
start, end = item, item
elif item == end + 1: # Next item in a range
end = item

View File

@ -245,7 +245,7 @@ class OfflineImap():
# Which ui to use? CLI option overrides config file.
ui_type = config.getdefault('general', 'ui', 'ttyui')
if options.interface != None:
if options.interface is not None:
ui_type = options.interface
if '.' in ui_type:
# Transform Curses.Blinkenlights -> Blinkenlights.