__init__.py added explicit from in raise exceptions

Remove the warnings:

repository/__init__.py:66:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
repository/__init__.py:74:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
This commit is contained in:
Rodolfo García Peñas (kix) 2020-11-01 12:58:39 +01:00
parent 0f19b6e63a
commit 6010437885

View File

@ -60,19 +60,19 @@ class Repository:
config = account.getconfig() config = account.getconfig()
try: try:
repostype = config.get('Repository ' + name, 'type').strip() repostype = config.get('Repository ' + name, 'type').strip()
except NoSectionError: except NoSectionError as exc:
errstr = ("Could not find section '%s' in configuration. Required " errstr = ("Could not find section '%s' in configuration. Required "
"for account '%s'." % ('Repository %s' % name, account)) "for account '%s'." % ('Repository %s' % name, account))
raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO, raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO,
exc_info()[2]) exc_info()[2]) from exc
try: try:
repo = typemap[repostype] repo = typemap[repostype]
except KeyError: except KeyError as exc:
errstr = "'%s' repository not supported for '%s' repositories." % \ errstr = "'%s' repository not supported for '%s' repositories." % \
(repostype, reqtype) (repostype, reqtype)
raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO, raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO,
exc_info()[2]) exc_info()[2]) from exc
return repo(name, account) return repo(name, account)