Skip to content

Fix deepcopy in from_anywidget.py #5134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions marimo/_plugins/ui/_impl/from_anywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import hashlib
import weakref
from copy import deepcopy
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Optional

Expand Down Expand Up @@ -190,6 +191,11 @@ def _convert_value(self, value: T) -> T:
self._prev_state = value
return value

def __deepcopy__(self, memo):
# Overriding UIElement deepcopy implementation
widget_deep_copy = deepcopy(self.widget, memo)
return from_anywidget(widget_deep_copy) # reuse caching

# After the widget has been initialized
# forward all setattr to the widget
def __setattr__(self, name: str, value: Any) -> None:
Expand Down
Loading