Skip to content

Commit cf0db35

Browse files
committed
Return default value if key is missing from configuration
1 parent e41a880 commit cf0db35

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/shelloracle/providers/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ def __get__(self, instance: Provider, owner: type[Provider]) -> T:
6161
# inspect.get_members from determining the object type
6262
raise AttributeError("Settings must be accessed through a provider instance.")
6363
config = get_config()
64-
return config["provider"][owner.name][self.name]
64+
try:
65+
return config["provider"][owner.name][self.name]
66+
except KeyError:
67+
return self.default
6568

6669

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

0 commit comments

Comments
 (0)