changeset 8521:24e867f846dd

chore: ruff spacing fixups, flow control and import reordering/removal
author John Rouillard <rouilj@ieee.org>
date Thu, 19 Feb 2026 21:48:55 -0500
parents 19152fd94fcf
children 82fc69e6d9d7
files roundup/scripts/roundup_mailgw.py
diffstat 1 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/scripts/roundup_mailgw.py	Mon Feb 02 23:41:36 2026 -0500
+++ b/roundup/scripts/roundup_mailgw.py	Thu Feb 19 21:48:55 2026 -0500
@@ -17,14 +17,19 @@
 """Command-line script stub that calls the roundup.mailgw.
 """
 from __future__ import print_function
+
 __docformat__ = 'restructuredtext'
 
 
-# --- patch sys.path to make sure 'import roundup' finds correct version
+import netrc
+import os
+import os.path as osp
+import re
+import socket
 import sys
-import os.path as osp
 from argparse import ArgumentParser, RawDescriptionHelpFormatter
 
+# --- patch sys.path to make sure 'import roundup' finds correct version
 thisdir = osp.dirname(osp.abspath(__file__))
 rootdir = osp.dirname(osp.dirname(thisdir))
 if (osp.exists(thisdir + '/__init__.py') and
@@ -33,16 +38,13 @@
     sys.path.insert(0, rootdir)
 # --/
 
-
-# python version check
-from roundup import version_check
-from roundup import __version__ as roundup_version
+# Python version check run for side effect.
+# Aborts program if Python version too old.
+from roundup import version_check  # noqa: E402 F401 I001
 
-import sys, os, re, getopt, socket, netrc
-
-from roundup import mailgw
-from roundup.i18n import _
-
+from roundup import __version__ as roundup_version  # noqa: E402
+from roundup import mailgw   # noqa: E402
+from roundup.i18n import _   # noqa: E402
 
 usage_epilog = """
 The roundup mail gateway may be called in one of the following ways:
@@ -140,6 +142,7 @@
 
 """
 
+
 def parse_arguments(argv):
     '''Handle the arguments to the program
     '''
@@ -164,13 +167,14 @@
             'organizations/oauth2/v2.0/token')
     return cmd, cmd.parse_args(argv)
 
+
 def main(argv):
     '''Handle the arguments to the program and initialise environment.
     '''
     cmd, args = parse_arguments(argv)
     if args.version:
         print('%s (python %s)' % (roundup_version, sys.version.split()[0]))
-        return
+        return None
 
     # figure the instance home
     if len(args.args) > 0:
@@ -234,17 +238,17 @@
     if source.startswith('pop'):
         ssl = source.endswith('s')
         return handler.do_pop(server, username, password, ssl)
-    elif source == 'apop':
+    if source == 'apop':
         return handler.do_apop(server, username, password)
-    elif source.startswith('imap'):
+    if source.startswith('imap'):
         d = {}
         if source.endswith('s'):
-            d.update(ssl = 1)
+            d.update(ssl=1)
         elif source.endswith('s_cram'):
-            d.update(ssl = 1, cram = 1)
+            d.update(ssl=1, cram=1)
         elif source == 'imaps_oauth':
-            d.update(ssl = 1, oauth = 1, oauth_path = args.oauth_directory)
-            d.update(token_endpoint = args.oauth_token_endpoint)
+            d.update(ssl=1, oauth=1, oauth_path=args.oauth_directory)
+            d.update(token_endpoint=args.oauth_token_endpoint)
         mailbox = ''
         if len(args.args) > 3:
             mailbox = args.args[3]
@@ -257,7 +261,7 @@
 
 
 def run():
-    sys.exit(main(sys.argv [1:]))
+    sys.exit(main(sys.argv[1:]))
 
 
 # call main

Roundup Issue Tracker: http://roundup-tracker.org/