Skip to content

Commit

Permalink
Component init -- Don't swallow all settings errors. Fixes #108
Browse files Browse the repository at this point in the history
  • Loading branch information
cboulay committed Apr 3, 2024
1 parent bd381d4 commit 8881a31
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/ezmsg/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ def __init__(self, *args, settings: Optional[Settings] = None, **kwargs):
for stream_name, stream in self.streams.items():
setattr(self, stream_name, stream)

try:
if settings is None:
# settings not supplied as a kwarg. Try to build it.
if len(args) > 0 and type(args[0]) == self.__class__.__settings_type__:
settings = args[0]
elif len(args) > 0 or len(kwargs) > 0:
settings = self.__class__.__settings_type__(*args, **kwargs)
else:
if settings is None:
# settings not supplied as a kwarg. Try to build it.
if len(args) > 0 and type(args[0]) == self.__class__.__settings_type__:
settings = args[0]
elif len(args) > 0 or len(kwargs) > 0:
settings = self.__class__.__settings_type__(*args, **kwargs)
else:
try:
# If we weren't supplied settings, we will try to
# instantiate the settings type from annotations
settings = self.__class__.__settings_type__()
except TypeError:
# We couldn't instantiate settings with default value
# We will rely on late configuration via apply_settings
pass
except TypeError:
# We couldn't instantiate settings with default value
# We will rely on late configuration via apply_settings
pass

if settings is not None:
self.apply_settings(settings)
Expand Down

0 comments on commit 8881a31

Please sign in to comment.