diff roundup/cgi/cgitb.py @ 6983:3129d73e8535

flake8 plus tests for cgitb.py flake8 fixes for cgitb.py. Also set up tests for functions in unit. Need tests before making some other changes in cgitb.py.
author John Rouillard <rouilj@ieee.org>
date Wed, 14 Sep 2022 22:35:23 -0400
parents 70e6b053193b
children 57f34b0b912c
line wrap: on
line diff
--- a/roundup/cgi/cgitb.py	Wed Sep 14 20:36:34 2022 -0400
+++ b/roundup/cgi/cgitb.py	Wed Sep 14 22:35:23 2022 -0400
@@ -7,13 +7,18 @@
 from __future__ import print_function
 __docformat__ = 'restructuredtext'
 
-import sys, os, keyword, linecache, tokenize, inspect
-import pydoc, traceback
+import inspect
+import keyword
+import linecache
+import os
+import pydoc
+import sys
+import tokenize
+import traceback
 
 from roundup.anypy.html import html_escape
-
+from roundup.anypy.strings import s2b
 from roundup.cgi import TranslationService
-from roundup.anypy.strings import s2b
 
 
 def get_translator(i18n=None):
@@ -45,8 +50,8 @@
     l = []
     for k in sorted(dict):
         v = dict[k]
-        l.append('<tr><td><strong>%s</strong></td><td>%s</td></tr>' % (k,
-            html_escape(repr(v))))
+        l.append('<tr><td><strong>%s</strong></td><td>%s</td></tr>' % (
+            k, html_escape(repr(v))))
     return '\n'.join(l)
 
 
@@ -72,9 +77,10 @@
                     s.append(_('<li>"%(name)s" (%(info)s)</li>')
                              % {'name': name, 'info': esc(repr(info))})
                 s = '\n'.join(s)
-                l.append(_('<li>Looking for "%(name)s", '
-                           'current path:<ol>%(path)s</ol></li>'
-                          ) % {'name': ti.name, 'path': s})
+                l.append(_(
+                    '<li>Looking for "%(name)s", '
+                    'current path:<ol>%(path)s</ol></li>'
+                ) % {'name': ti.name, 'path': s})
             else:
                 l.append(_('<li>In %s</li>') % esc(str(ti)))
         if '__traceback_supplement__' in locals:
@@ -101,7 +107,7 @@
     'line': context.position[0],
     'globals': niceDict('    ', context.global_vars),
     'locals': niceDict('    ', context.local_vars)
-})
+   })
 
     l.append('''
 </ol>
@@ -164,7 +170,7 @@
             if type == tokenize.NAME and token not in keyword.kwlist:
                 if token not in names:
                     names.append(token)
-            if type == tokenize.NEWLINE: raise IndexError
+            if type == tokenize.NEWLINE: raise IndexError       # noqa: E701
 
         def linereader(file=file, lnum=[lnum]):
             line = s2b(linecache.getline(file, lnum[0]))

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