Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
edublancas committed Aug 11, 2023
1 parent 7d6fefa commit bb03233
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ploomber_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,28 @@ def __init__(self):
else:
try:
content = self._load_from_file()
loaded = True
loaded_from_file = True
except Exception as e:
warnings.warn(
f"Error loading {str(path)!r}: {e}\n\n"
"reverting to default values"
)
loaded = False
loaded_from_file = False
content = self._get_annotation_values()

if loaded and not isinstance(content, Mapping):
if loaded_from_file and not isinstance(content, Mapping):
warnings.warn(
f"Error loading {str(path)!r}. Expected a dictionary "
f"but got {type(content).__name__}, "
"reverting to default values"
)
content = self._get_annotation_values()

self._write_attr_changes = False
# if we loaded from file, we don't need to write the changes, since
# we'd be overwriting the file with the same content
self._write_attr_changes = not loaded_from_file
self._set_data(content)

self._write_attr_changes = True

def _load_from_file(self):
Expand Down

0 comments on commit bb03233

Please sign in to comment.