From 1a529b6b0e4dc791ee2dbca40c7a671ff30bdd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 30 Aug 2020 11:27:03 +0200 Subject: [PATCH] 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) --- offlineimap/CustomConfig.py | 2 +- offlineimap/accounts.py | 12 ++++++------ offlineimap/imapserver.py | 12 ++++++------ offlineimap/imaputil.py | 2 +- offlineimap/init.py | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/offlineimap/CustomConfig.py b/offlineimap/CustomConfig.py index 689270b..47a5a41 100644 --- a/offlineimap/CustomConfig.py +++ b/offlineimap/CustomConfig.py @@ -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) diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 84c8579..77d8f0e 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -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() diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 973deb2..bbc9567 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -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. diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py index c9ff7d0..c510b3d 100644 --- a/offlineimap/imaputil.py +++ b/offlineimap/imaputil.py @@ -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 diff --git a/offlineimap/init.py b/offlineimap/init.py index be3e448..0ed3316 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -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.