Skip to content

Commit

Permalink
Raise KeyError instead of AssertionError
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Nov 24, 2021
1 parent 51212d9 commit 40cb34b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion optuna/integration/allennlp/_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def prefix(self) -> str:

def _get_key(self, name: str) -> str:
key = self.NAME_OF_KEY.get(name)
assert key is not None, f"{name} is not found in `{self.NAME_OF_PATH}`."
if key is None:
raise KeyError(f"{name} is not found in `{self.NAME_OF_PATH}`.")
return key

def set_value(self, name: str, value: str) -> None:
Expand Down

0 comments on commit 40cb34b

Please sign in to comment.