From 7118641d78a90c4f0cadbc4e63c80d203fdb625a Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Mon, 19 Dec 2022 09:41:29 +1100 Subject: [PATCH] Use identity operators for comparison to None singleton. PEP 8 specifies: * Comparisons to singletons like None should always be done with `is` or `is not`, never the equality operators. --- auth-mastodon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auth-mastodon.py b/auth-mastodon.py index 1e5a058..5c39435 100644 --- a/auth-mastodon.py +++ b/auth-mastodon.py @@ -138,16 +138,16 @@ def get_password(user, host): cursor.execute(db_query_getpass, {"user": user.lower(), "host": host}) data = cursor.fetchone() cursor.close() - return data[0] if data != None else None + return data[0] if data is not None else None def isuser(user, host): - return get_password(user, host) != None + return get_password(user, host) is not None def auth(user, host, password): db_password = get_password(user, host) - if db_password == None: + if db_password is None: logging.debug("Wrong username: %s@%s" % (user, host)) return False else: