Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 4dfe87a commit 63d19f7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sdgx/data_models/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ def set(self, key: str, value: Any):
raise MetadataInitError("Cannot set _extend directly")

old_value = self.get(key)
if key in self.model_fields and key not in self.tag_fields and key not in self.format_fields:
if (
key in self.model_fields
and key not in self.tag_fields
and key not in self.format_fields
):
raise MetadataInitError(
f"Set {key} not in tag_fields, try set it directly as m.{key} = value"
)
Expand Down Expand Up @@ -208,11 +212,11 @@ def add(self, key: str, values: str | Iterable[str]):

# dict support, this prevents the value in the key-value pair from being discarded
if isinstance(values, dict):
# already in fields that contains dict
# already in fields that contains dict
if key in list(self.format_fields):
self.get(key).update(values)
# in extend

# in extend
if self._extend.get(key, None) is None:
self._extend[key] = values
else:
Expand Down

0 comments on commit 63d19f7

Please sign in to comment.