Skip to content

Commit dcae170

Browse files
Adjusted to PEP8
1 parent 569df6e commit dcae170

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/hermes_toml/harvest.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""A hermes harvest plugin that harvests the .toml file of the project"""
22

3-
import os
4-
import pathlib
5-
import toml
6-
73
from contextlib import chdir
84
from email.utils import getaddresses
5+
6+
import pathlib
7+
import toml
98
from pydantic import BaseModel
109

1110
from hermes.commands.harvest.base import HermesHarvestCommand, HermesHarvestPlugin
@@ -180,8 +179,8 @@ def handle_person_in_unknown_format(cls, persons):
180179
try:
181180
[(name, email)] = getaddresses([person])
182181
return cls.remove_forbidden_keys({"name":name, "email":email})
183-
except ValueError:
184-
raise ValueError("Wrong string format for name (and email).")
182+
except ValueError as exc:
183+
raise ValueError("Wrong string format for name (and email).") from exc
185184

186185
else:
187186
#if the person isn't a dictionary raise an Error
@@ -197,13 +196,13 @@ def handle_person_in_unknown_format(cls, persons):
197196
#the 'person' may be an empty dictionary if all keys are incorrect
198197
return cls.remove_forbidden_keys(persons)
199198

200-
elif isinstance(persons, str):
199+
if isinstance(persons, str):
201200
#try to parse the string
202201
try:
203202
[(name, email)] = getaddresses([persons])
204203
return cls.remove_forbidden_keys({"name":name, "email":email})
205-
except ValueError:
206-
raise ValueError("Wrong string format for name (and email).")
204+
except ValueError as exc:
205+
raise ValueError("Wrong string format for name (and email).") from exc
207206

208207
#raise an error if the persons data is not in the right format
209208
raise ValueError("A person must be a dict or special string.")

0 commit comments

Comments
 (0)