remove bare excepts

This commit is contained in:
Matthias Bernt
2022-01-17 11:03:06 +01:00
parent 96654f8882
commit a7edfaac1b
8 changed files with 28 additions and 16 deletions
+6 -2
View File
@@ -8,13 +8,17 @@ of the tool publish results.
def lint_citations(tool_xml, lint_ctx):
"""Ensure tool contains at least one valid citation."""
root = tool_xml.getroot()
if root is not None:
root_line = root.sourceline
else:
root_line = 1
citations = root.findall("citations")
if len(citations) > 1:
lint_ctx.error("More than one citation section found, behavior undefined.", line=citations[1].sourceline)
return
if len(citations) == 0:
lint_ctx.warn("No citations found, consider adding citations to your tool.", line=root.sourceline)
lint_ctx.warn("No citations found, consider adding citations to your tool.", line=root_line)
return
valid_citations = 0
@@ -32,4 +36,4 @@ def lint_citations(tool_xml, lint_ctx):
valid_citations += 1
if valid_citations > 0:
lint_ctx.valid(f"Found {valid_citations} likely valid citations.", line=root.sourceline)
lint_ctx.valid(f"Found {valid_citations} likely valid citations.", line=root_line)
+5 -1
View File
@@ -8,13 +8,17 @@ from supplied inputs.
def lint_command(tool_xml, lint_ctx):
"""Ensure tool contains exactly one command and check attributes."""
root = tool_xml.getroot()
if root is not None:
root_line = root.sourceline
else:
root_line = 1
commands = root.findall("command")
if len(commands) > 1:
lint_ctx.error("More than one command tag found, behavior undefined.", line=commands[1].sourceline)
return
if len(commands) == 0:
lint_ctx.error("No command tag found, must specify a command template to execute.", line=root.sourceline)
lint_ctx.error("No command tag found, must specify a command template to execute.", line=root_line)
return
command = get_command(tool_xml)
+1 -1
View File
@@ -31,7 +31,7 @@ def lint_general(tool_source, lint_ctx):
tool_xml = getattr(tool_source, "xml_tree", None)
try:
tool_line = tool_xml.find("./tool").sourceline
except:
except AttributeError:
tool_line = 0
version = tool_source.parse_version() or ''
parsed_version = packaging.version.parse(version)
+8 -3
View File
@@ -7,15 +7,20 @@ from galaxy.util import (
def lint_help(tool_xml, lint_ctx):
"""Ensure tool contains exactly one valid RST help block."""
# determine line to report for general problems with outputs
# determine line to report for general problems with help
root = tool_xml.getroot()
if root is not None:
root_line = root.sourceline
else
root_line = 1
helps = root.findall("help")
if len(helps) > 1:
lint_ctx.error("More than one help section found, behavior undefined.", line=helps[1].sourceline)
return
if len(helps) == 0:
lint_ctx.warn("No help section found, consider adding a help section to your tool.", line=root.sourceline)
lint_ctx.warn("No help section found, consider adding a help section to your tool.", line=root_line)
return
help = helps[0].text or ''
@@ -23,7 +28,7 @@ def lint_help(tool_xml, lint_ctx):
lint_ctx.warn("Help section appears to be empty.", line=helps[0].sourceline)
return
lint_ctx.valid("Tool contains help section.", line=root.sourceline)
lint_ctx.valid("Tool contains help section.", line=root_line)
invalid_rst = rst_invalid(help)
if "TODO" in help:
+1 -1
View File
@@ -49,7 +49,7 @@ def lint_inputs(tool_xml, lint_ctx):
# determine line to report for general problems with outputs
try:
tool_line = tool_xml.find("./tool").sourceline
except:
except AttributeError:
tool_line = 0
datasource = is_datasource(tool_xml)
inputs = tool_xml.findall("./inputs//param")
+1 -1
View File
@@ -9,7 +9,7 @@ def lint_output(tool_xml, lint_ctx):
# determine line to report for general problems with outputs
try:
tool_line = tool_xml.find("./tool").sourceline
except:
except AttributeError:
tool_line = 0
outputs = tool_xml.findall("./outputs")
if len(outputs) == 0:
+1 -1
View File
@@ -7,7 +7,7 @@ def lint_stdio(tool_source, lint_ctx):
# determine line to report for general problems with stdio
try:
tool_line = tool_xml.find("./tool").sourceline
except:
except AttributeError:
tool_line = 0
stdios = tool_xml.findall("./stdio") if tool_xml else []
+5 -6
View File
@@ -5,15 +5,14 @@ from ._util import is_datasource
# Misspelled so as not be picked up by nosetests.
def lint_tsts(tool_xml, lint_ctx):
# determine line to report for general problems with tests
try:
tests_line = tool_xml.find("./tool").sourceline
except:
tests_line = 0
try:
tests_line = tool_xml.find("./tests").sourceline
except:
except AttributeError:
tests_line = 1
try:
tests_line = tool_xml.find("./tool").sourceline
except AttributeError:
pass
tests = tool_xml.findall("./tests/test")
datasource = is_datasource(tool_xml)
if not tests and not datasource: