mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-18 12:50:30 +08:00
* fix #3282 avoid in-place dict updates * add tests and changelog for PR3405
This commit is contained in:
parent
fddf376784
commit
ee1a76fd10
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,6 +40,7 @@ demo/*/config.json
|
||||
|
||||
# Etc
|
||||
.idea/*
|
||||
.vscode/*
|
||||
.DS_Store
|
||||
*.bak
|
||||
workspace.code-workspace
|
||||
|
1471
CHANGELOG.md
1471
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@ -251,6 +251,7 @@ class Block:
|
||||
|
||||
@classmethod
|
||||
def get_specific_update(cls, generic_update: Dict[str, Any]) -> Dict:
|
||||
generic_update = generic_update.copy()
|
||||
del generic_update["__type__"]
|
||||
specific_update = cls.update(**generic_update)
|
||||
return specific_update
|
||||
|
@ -484,6 +484,22 @@ class TestBlocksPostprocessing:
|
||||
output = demo.postprocess_data(0, gr.update(value="NO_VALUE"), state={})
|
||||
assert output[0]["value"] == "NO_VALUE"
|
||||
|
||||
def test_blocks_does_not_del_dict_keys_inplace(self):
|
||||
with gr.Blocks() as demo:
|
||||
im_list = [gr.Image() for i in range(2)]
|
||||
|
||||
def change_visibility(value):
|
||||
return [gr.update(visible=value)] * 2
|
||||
|
||||
checkbox = gr.Checkbox(value=True, label="Show image")
|
||||
checkbox.change(change_visibility, inputs=checkbox, outputs=im_list)
|
||||
|
||||
output = demo.postprocess_data(0, [gr.update(visible=False)] * 2, state={})
|
||||
assert output == [
|
||||
{"visible": False, "__type__": "update"},
|
||||
{"visible": False, "__type__": "update"},
|
||||
]
|
||||
|
||||
def test_blocks_returns_correct_output_dict_single_key(self):
|
||||
with gr.Blocks() as demo:
|
||||
num = gr.Number()
|
||||
|
Loading…
x
Reference in New Issue
Block a user