Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-migas committed Aug 14, 2024
1 parent 53b6550 commit 89e715f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .idea/koyo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/koyo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ def output_path(self) -> Path:

def update(self, save: bool = True, **kwargs: ty.Any) -> None:
"""Update configuration and save to file."""
changed = False
for key, value in kwargs.items():
if hasattr(self, key):
old_value = getattr(self, key)
try:
setattr(self, key, value)
if old_value != getattr(self, key):
changed = True
except Exception as e:
logger.warning(f"Failed to set {key}={value}: {e}")
else:
logger.warning(f"Unknown key {key}={value} - perhaps it was deprecated?")
if save:
if save and changed:
with suppress(OSError, PermissionError):
self.save()

Expand Down

0 comments on commit 89e715f

Please sign in to comment.