Skip to content

Commit

Permalink
mypy: Ignore 'osc_msg' injected into exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Oct 17, 2023
1 parent 409f0a7 commit df39d9d
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3777,12 +3777,12 @@ def show_project_meta(apiurl: str, prj: str, rev: Optional[str] = None, blame=No
f = http_GET(url)
except HTTPError as e:
error_help = "%d" % e.code
os_err = e.hdrs.get('X-Opensuse-Errorcode')
os_err = e.hdrs.get('X-Opensuse-Errorcode') # type: ignore[attr-defined]
if os_err:
error_help = "%s (%d) project: %s" % (os_err, e.code, prj)
if e.code == 404 and os_err == 'unknown_package':
error_help = 'option -r|--revision is not supported by this OBS version'
e.osc_msg = 'BuildService API error: %s' % error_help
e.osc_msg = 'BuildService API error: %s' % error_help # type: ignore[attr-defined]
raise
else:
if blame:
Expand Down Expand Up @@ -3813,7 +3813,7 @@ def show_package_trigger_reason(apiurl: str, prj: str, pac: str, repo: str, arch
f = http_GET(url)
return f.read()
except HTTPError as e:
e.osc_msg = 'Error getting trigger reason for project \'%s\' package \'%s\'' % (prj, pac)
e.osc_msg = 'Error getting trigger reason for project \'%s\' package \'%s\'' % (prj, pac) # type: ignore[attr-defined]
raise


Expand All @@ -3830,7 +3830,7 @@ def show_package_meta(apiurl: str, prj: str, pac: str, meta=False, blame=None):
f = http_GET(url)
return f.readlines()
except HTTPError as e:
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (unquote(prj), pac)
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (unquote(prj), pac) # type: ignore[attr-defined]
raise


Expand All @@ -3855,7 +3855,7 @@ def show_attribute_meta(apiurl: str, prj: str, pac, subpac, attribute, with_defa
f = http_GET(url)
return f.readlines()
except HTTPError as e:
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac)
e.osc_msg = 'Error getting meta for project \'%s\' package \'%s\'' % (prj, pac) # type: ignore[attr-defined]
raise


Expand Down Expand Up @@ -3948,7 +3948,7 @@ def show_pattern_metalist(apiurl: str, prj: str):
f = http_GET(url)
tree = ET.parse(f)
except HTTPError as e:
e.osc_msg = 'show_pattern_metalist: Error getting pattern list for project \'%s\'' % prj
e.osc_msg = 'show_pattern_metalist: Error getting pattern list for project \'%s\'' % prj # type: ignore[attr-defined]
raise
r = sorted(node.get('name') for node in tree.getroot())
return r
Expand All @@ -3960,7 +3960,7 @@ def show_pattern_meta(apiurl: str, prj: str, pattern: str):
f = http_GET(url)
return f.readlines()
except HTTPError as e:
e.osc_msg = 'show_pattern_meta: Error getting pattern \'%s\' for project \'%s\'' % (pattern, prj)
e.osc_msg = 'show_pattern_meta: Error getting pattern \'%s\' for project \'%s\'' % (pattern, prj) # type: ignore[attr-defined]
raise


Expand Down Expand Up @@ -4709,7 +4709,7 @@ def create_submit_request(
root = ET.parse(f).getroot()
r = root.get('id')
except HTTPError as e:
if e.hdrs.get('X-Opensuse-Errorcode') == "submit_request_rejected":
if e.hdrs.get('X-Opensuse-Errorcode') == "submit_request_rejected": # type: ignore[attr-defined]
print('WARNING: As the project is in maintenance, a maintenance incident request is')
print('WARNING: being created (instead of a regular submit request). If this is not your')
print('WARNING: intention please revoke it to avoid unnecessary work for all involved parties.')
Expand Down Expand Up @@ -6190,7 +6190,8 @@ def branch_pkg(
raise oscerr.APIError('failed to branch: %s' % summary.text)
m = re.match(r"branch target package already exists: (\S+)/(\S+)", summary.text)
if not m:
e.msg += '\n' + summary.text
assert summary.text
e.msg += '\n' + summary.text # type: ignore[attr-defined]
raise
return (True, m.group(1), m.group(2), None, None)

Expand Down Expand Up @@ -7304,7 +7305,7 @@ def runservice(apiurl: str, prj: str, package: str):
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'could not trigger service run for project \'%s\' package \'%s\'' % (prj, package)
e.osc_msg = 'could not trigger service run for project \'%s\' package \'%s\'' % (prj, package) # type: ignore[attr-defined]
raise

root = ET.parse(f).getroot()
Expand All @@ -7317,7 +7318,7 @@ def waitservice(apiurl: str, prj: str, package: str):
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'The service for project \'%s\' package \'%s\' failed' % (prj, package)
e.osc_msg = 'The service for project \'%s\' package \'%s\' failed' % (prj, package) # type: ignore[attr-defined]
raise

root = ET.parse(f).getroot()
Expand All @@ -7334,7 +7335,7 @@ def mergeservice(apiurl: str, prj: str, package: str):
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'could not merge service files in project \'%s\' package \'%s\'' % (prj, package)
e.osc_msg = 'could not merge service files in project \'%s\' package \'%s\'' % (prj, package) # type: ignore[attr-defined]
raise

root = ET.parse(f).getroot()
Expand All @@ -7356,7 +7357,7 @@ def rebuild(apiurl: str, prj: str, package: str, repo: str, arch: str, code=None
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package)
e.osc_msg = 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package) # type: ignore[attr-defined]
raise

root = ET.parse(f).getroot()
Expand Down Expand Up @@ -7528,17 +7529,17 @@ def cmdbuild(
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = '%s command failed for project %s' % (cmd, project)
e.osc_msg = '%s command failed for project %s' % (cmd, project) # type: ignore[attr-defined]
if package:
e.osc_msg += ' package %s' % package
e.osc_msg += ' package %s' % package # type: ignore[attr-defined]
if arch:
e.osc_msg += ' arch %s' % arch
e.osc_msg += ' arch %s' % arch # type: ignore[attr-defined]
if repo:
e.osc_msg += ' repository %s' % repo
e.osc_msg += ' repository %s' % repo # type: ignore[attr-defined]
if code:
e.osc_msg += ' code=%s' % code
e.osc_msg += ' code=%s' % code # type: ignore[attr-defined]
if sysrq:
e.osc_msg += ' sysrq=%s' % code
e.osc_msg += ' sysrq=%s' % code # type: ignore[attr-defined]
raise

root = ET.parse(f).getroot()
Expand Down Expand Up @@ -7765,7 +7766,7 @@ def set_link_rev(apiurl: str, project: str, package: str, revision="", expand=Fa
f = http_GET(url)
root = ET.parse(f).getroot()
except HTTPError as e:
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project) # type: ignore[attr-defined]
raise
revision = _set_link_rev(apiurl, project, package, root, revision, expand=expand)
l = ET.tostring(root, encoding=ET_ENCODING)
Expand Down

0 comments on commit df39d9d

Please sign in to comment.