Skip to content

Commit e4dbd64

Browse files
committed
Minor lint improvements
1 parent 9f2b988 commit e4dbd64

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

emailproxy.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__author__ = 'Simon Robinson'
77
__copyright__ = 'Copyright (c) 2024 Simon Robinson'
88
__license__ = 'Apache 2.0'
9-
__version__ = '2024-09-24' # ISO 8601 (YYYY-MM-DD)
9+
__version__ = '2024-10-04' # ISO 8601 (YYYY-MM-DD)
1010
__package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only
1111

1212
import abc
@@ -1153,7 +1153,7 @@ def get_service_account_authorisation_token(key_type, key_path_or_contents, oaut
11531153
"""Requests an authorisation token via a Service Account key (currently Google Cloud only)"""
11541154
import json
11551155
try:
1156-
import requests
1156+
import requests # noqa: F401 - requests is required as the default transport for google-auth
11571157
import google.oauth2.service_account
11581158
import google.auth.transport.requests
11591159
except ModuleNotFoundError as e:
@@ -1359,8 +1359,8 @@ def handle_error(self):
13591359
'CERTIFICATE_VERIFY_FAILED', 'TLSV1_ALERT_PROTOCOL_VERSION', 'TLSV1_ALERT_UNKNOWN_CA',
13601360
'UNSUPPORTED_PROTOCOL', 'record layer failure', APP_PACKAGE]
13611361
error_type, value = Log.get_last_error()
1362-
if error_type == OSError and value.errno == 0 or issubclass(error_type, ssl.SSLError) and \
1363-
any(i in value.args[1] for i in ssl_errors) or error_type == FileNotFoundError:
1362+
if error_type is OSError and value.errno == 0 or issubclass(error_type, ssl.SSLError) and \
1363+
any(i in value.args[1] for i in ssl_errors) or error_type is FileNotFoundError:
13641364
Log.error('Caught connection error in', self.info_string(), ':', error_type, 'with message:', value)
13651365
if hasattr(self, 'custom_configuration') and hasattr(self, 'proxy_type'):
13661366
if self.proxy_type == 'SMTP':
@@ -1485,7 +1485,7 @@ def handle_close(self):
14851485
error_type, value = Log.get_last_error()
14861486
if error_type and value:
14871487
message = 'Caught connection error (client)'
1488-
if error_type == ConnectionResetError:
1488+
if error_type is ConnectionResetError:
14891489
message = '%s [ Are you attempting an encrypted connection to a non-encrypted server? ]' % message
14901490
Log.info(self.info_string(), message, '-', error_type.__name__, ':', value)
14911491
self.close()
@@ -1943,9 +1943,9 @@ def send(self, byte_data, censor_log=False):
19431943

19441944
def handle_error(self):
19451945
error_type, value = Log.get_last_error()
1946-
if error_type == TimeoutError and value.errno == errno.ETIMEDOUT or \
1946+
if error_type is TimeoutError and value.errno == errno.ETIMEDOUT or \
19471947
issubclass(error_type, ConnectionError) and value.errno in [errno.ECONNRESET, errno.ECONNREFUSED] or \
1948-
error_type == OSError and value.errno in [0, errno.ENETDOWN, errno.ENETUNREACH, errno.EHOSTDOWN,
1948+
error_type is OSError and value.errno in [0, errno.ENETDOWN, errno.ENETUNREACH, errno.EHOSTDOWN,
19491949
errno.EHOSTUNREACH]:
19501950
# TimeoutError 60 = 'Operation timed out'; ConnectionError 54 = 'Connection reset by peer', 61 = 'Connection
19511951
# refused; OSError 0 = 'Error' (typically network failure), 50 = 'Network is down', 51 = 'Network is
@@ -1965,7 +1965,7 @@ def handle_close(self):
19651965
error_type, value = Log.get_last_error()
19661966
if error_type and value:
19671967
message = 'Caught connection error (server)'
1968-
if error_type == OSError and value.errno in [errno.ENOTCONN, 10057]:
1968+
if error_type is OSError and value.errno in [errno.ENOTCONN, 10057]:
19691969
# OSError 57 or 10057 = 'Socket is not connected'
19701970
message = '%s [ Client attempted to send command without waiting for server greeting ]' % message
19711971
Log.info(self.info_string(), message, '-', error_type.__name__, ':', value)
@@ -2382,9 +2382,9 @@ def restart(self):
23822382
def handle_error(self):
23832383
error_type, value = Log.get_last_error()
23842384
if error_type == socket.gaierror and value.errno in [-2, 8, 11001] or \
2385-
error_type == TimeoutError and value.errno == errno.ETIMEDOUT or \
2385+
error_type is TimeoutError and value.errno == errno.ETIMEDOUT or \
23862386
issubclass(error_type, ConnectionError) and value.errno in [errno.ECONNRESET, errno.ECONNREFUSED] or \
2387-
error_type == OSError and value.errno in [0, errno.EINVAL, errno.ENETDOWN, errno.EHOSTUNREACH]:
2387+
error_type is OSError and value.errno in [0, errno.EINVAL, errno.ENETDOWN, errno.EHOSTUNREACH]:
23882388
# gaierror -2 or 8 = 'nodename nor servname provided, or not known' / 11001 = 'getaddrinfo failed' (caused
23892389
# by getpeername() failing due to no connection); TimeoutError 60 = 'Operation timed out'; ConnectionError
23902390
# 54 = 'Connection reset by peer', 61 = 'Connection refused; OSError 0 = 'Error' (local SSL failure),
@@ -2874,7 +2874,7 @@ def create_authorisation_menu(self):
28742874
else:
28752875
usernames = []
28762876
for request in self.authorisation_requests:
2877-
if not request['username'] in usernames:
2877+
if request['username'] not in usernames:
28782878
items.append(pystray.MenuItem(request['username'], self.authorise_account))
28792879
usernames.append(request['username'])
28802880
items.append(pystray.Menu.SEPARATOR)

0 commit comments

Comments
 (0)