Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Jan 20, 2025
1 parent 603ee83 commit 238b295
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions packages/models-library/src/models_library/user_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def to_db(self) -> dict:
@classmethod
def update_preference_default_value(cls, new_default: Any) -> None:
expected_type = get_type(
cls.model_fields["value"]
) # pylint: disable=unsubscriptable-object
cls.model_fields["value"] # pylint: disable=unsubscriptable-object
)
detected_type = type(new_default)
if expected_type != detected_type:
msg = (
Expand All @@ -109,20 +109,19 @@ def update_preference_default_value(cls, new_default: Any) -> None:
raise TypeError(msg)

if (
cls.model_fields["value"].default is None
): # pylint: disable=unsubscriptable-object
cls.model_fields[
cls.model_fields["value"].default # pylint: disable=unsubscriptable-object
is None
):
cls.model_fields[ # pylint: disable=unsubscriptable-object
"value"
].default_factory = (
lambda: new_default
) # pylint: disable=unsubscriptable-object
].default_factory = lambda: new_default
else:
cls.model_fields[
cls.model_fields[ # pylint: disable=unsubscriptable-object
"value"
].default = new_default # pylint: disable=unsubscriptable-object
cls.model_fields[
].default = new_default
cls.model_fields[ # pylint: disable=unsubscriptable-object
"value"
].default_factory = None # pylint: disable=unsubscriptable-object
].default_factory = None

cls.model_rebuild(force=True)

Expand Down

0 comments on commit 238b295

Please sign in to comment.