Skip to content

Commit

Permalink
Return default value if key is missing from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
djcopley committed Apr 27, 2024
1 parent 548eabc commit aef0344
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/shelloracle/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def __get__(self, instance: Provider, owner: type[Provider]) -> T:
# inspect.get_members from determining the object type
raise AttributeError("Settings must be accessed through a provider instance.")
config = get_config()
return config["provider"][owner.name][self.name]
try:
return config["provider"][owner.name][self.name]
except KeyError:
return self.default


def _providers() -> dict[str, type[Provider]]:
Expand Down

0 comments on commit aef0344

Please sign in to comment.