Skip to content

Commit

Permalink
Change parse_obj to use deepcopy rather than editing in place
Browse files Browse the repository at this point in the history
  • Loading branch information
theyostalservice committed Nov 14, 2024
1 parent 10794b9 commit 019d648
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions dbt_semantic_interfaces/implementations/saved_query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from copy import deepcopy
from typing import Any, List, Optional, Union

from typing_extensions import Self, override
Expand Down Expand Up @@ -58,9 +59,10 @@ def _implements_protocol(self) -> SavedQuery:

@classmethod
def parse_obj(cls, input: Any) -> Self: # noqa
if isinstance(input, dict):
if isinstance(input.get("tags"), str):
input["tags"] = [input["tags"]]
if isinstance(input.get("tags"), list):
input["tags"].sort()
return super(HashableBaseModel, cls).parse_obj(input)
data = deepcopy(input)
if isinstance(data, dict):
if isinstance(data.get("tags"), str):
data["tags"] = [data["tags"]]
if isinstance(data.get("tags"), list):
data["tags"].sort()
return super(HashableBaseModel, cls).parse_obj(data)

0 comments on commit 019d648

Please sign in to comment.