Skip to content

Commit

Permalink
style: fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mikapfl committed Jan 8, 2024
1 parent a71daec commit cb8ccf5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions unfccc_di_api/unfccc_di_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ def __init__(

try:
parties_raw = self._get(f"parties/{party_category}")
except requests.JSONDecodeError:
except requests.JSONDecodeError as e:
raise RuntimeError(
"Access to the UNFCCC API denied - see"
" https://github.com/pik-primap/unfccc_di_api#warning for solutions"
)
) from e
parties_entries = []
for entry in parties_raw:
if entry["categoryCode"] == party_category and entry["name"] != "Groups":
Expand Down Expand Up @@ -469,7 +469,7 @@ def query(
"try `UNFCCCSingleCategoryApiReader.parties` for a list of"
" valid codes"
)
raise ValueError(f"Unknown party `{code}`, {help}!")
raise ValueError(f"Unknown party `{code}`, {help}!") from None

# always query all years
year_ids = list(self.years.index)
Expand Down Expand Up @@ -584,9 +584,8 @@ def _parse_raw_answer(
data.append(row)

df = pd.DataFrame(data)
df.sort_values(
df = df.sort_values(
["party", "category", "classification", "measure", "gas", "unit", "year"],
inplace=True,
)
df.drop_duplicates(inplace=True)
df.reset_index(inplace=True, drop=True)
Expand Down Expand Up @@ -659,7 +658,7 @@ def _name_id(df, name: str, key: str = "name") -> int:
try:
return int(df[df[key] == name].index[0])
except IndexError:
raise KeyError(name)
raise KeyError(name) from None

def show_category_hierarchy(self) -> None:
"""Print the hierarchy of categories and their IDs."""
Expand Down

0 comments on commit cb8ccf5

Please sign in to comment.