Skip to content

Commit

Permalink
copy product with pydantic model_copy instead of copy.deepcopy (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
philvarner authored Nov 21, 2024
1 parent b3e4561 commit 3125efc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/stapi_fastapi/models/product.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from copy import deepcopy
from enum import Enum
from typing import TYPE_CHECKING, Literal, Optional, Self

Expand Down Expand Up @@ -78,7 +77,7 @@ def with_links(self: Self, links: list[Link] | None = None) -> Self:
if not links:
return self

new = deepcopy(self)
new = self.model_copy(deep=True)
new.links.extend(links)
return new

Expand Down

0 comments on commit 3125efc

Please sign in to comment.