|
From: <mi...@us...> - 2022-03-05 23:29:22
|
Revision: 9033
http://sourceforge.net/p/docutils/code/9033
Author: milde
Date: 2022-03-05 23:29:18 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Do not use bare 'except'.
flake8 rule E722
Exception: as catchall, if
* the right thing to do does not depend on the error
* any error is reported or risen again.
Modified Paths:
--------------
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/io.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -31,7 +31,7 @@
locale_encoding = "UTF-8"
else:
locale_encoding = None
-except: # any other problems determining the locale -> use None
+except: # noqa any other problems determining the locale -> use None
locale_encoding = None
try:
codecs.lookup(locale_encoding or '')
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/nodes.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -1792,7 +1792,7 @@
children = (p,) + children
try:
Element.__init__(self, rawsource, *children, **attributes)
- except:
+ except: # noqa catchall
print('system_message: children=%r' % (children,))
raise
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -263,7 +263,7 @@
else:
transitions = None
state = self.get_state(next_state)
- except:
+ except: # noqa catchall
if self.debug:
self.error()
raise
@@ -674,7 +674,7 @@
try:
del self.transitions[name]
self.transition_order.remove(name)
- except:
+ except: # noqa catchall
raise UnknownTransitionError(name)
def make_transition(self, name, next_state=None):
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -72,7 +72,7 @@
locale_encoding = "UTF-8"
else:
locale_encoding = None
- except: # any other problems determining the locale -> use None
+ except: # noqa any other problems determining the locale -> use None
locale_encoding = None
try:
codecs.lookup(locale_encoding or '') # None -> ''
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -898,7 +898,7 @@
try:
locale.setlocale(locale.LC_ALL, '') # set to user defaults
defaultlanguage = locale.getdefaultlocale()[0]
- except:
+ except: # noqa catchall
defaultlanguage = 'en'
# Normalize and drop unsupported subtags:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -1080,7 +1080,7 @@
while True:
try:
c_start = rowspans.pop()
- except:
+ except IndexError:
break
cline += '\\cline{%d-%d}\n' % (c_start, c_start)
res.append(cline)
@@ -1089,13 +1089,13 @@
def set_rowspan(self, cell, value):
try:
self._rowspan[cell] = value
- except:
+ except IndexError:
pass
def get_rowspan(self, cell):
try:
return self._rowspan[cell]
- except:
+ except IndexError:
return 0
def get_entry_number(self):
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -78,7 +78,7 @@
try:
import mypdb as pdb
-except:
+except ImportError:
import pdb
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -71,7 +71,7 @@
errstr_8bit_path = """\
Cannot encode input file path "\u043c\u0438\u0440.txt" (wrong locale?).\
"""
-except:
+except FileNotFoundError:
errstr_8bit_path = """\
InputError: [Errno 2] No such file or directory: '\u043c\u0438\u0440.txt'.\
"""
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/tox.ini 2022-03-05 23:29:18 UTC (rev 9033)
@@ -38,10 +38,6 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E711, # comparison to None should be 'if cond is not None:'
- E713, # test for membership should be 'not in'
- E721, # do not compare types, use 'isinstance()'
- E722, # do not use bare 'except'
E731, # do not assign a lambda expression, use a def
E741, # ambiguous variable name 'a'
W503, # line break before binary operator
@@ -95,3 +91,6 @@
# raw string test samples with trailing whitespace
test/test_writers/test_manpage.py:E121,E128,E501,W291
test/test_writers/test_latex2e.py:E122,E128,E501,W291,W293
+
+ # ignore all errors when setting locale
+ tools/*.py:E722
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|