Skip to content

Ensure edit_readonly resets class and instance level parameters - #8371

Merged
philippjfr merged 3 commits into
mainfrom
fix_edit_readonly
Jan 21, 2026
Merged

Ensure edit_readonly resets class and instance level parameters#8371
philippjfr merged 3 commits into
mainfrom
fix_edit_readonly

Conversation

@maximlt

@maximlt maximlt commented Jan 8, 2026

Copy link
Copy Markdown
Member

Fixes #7999

Code adapted from edit_constant's code in Param. Example from the issue:

from panel.util.parameters import edit_readonly
import param

class Container(param.Parameterized):
    constant = param.Number(default=0, constant=True)
    readonly = param.Number(default=1, readonly=True)

obj = Container()

with edit_readonly(obj):
    obj.constant = 2
    obj.readonly = 3


print(f"{obj.constant = }, {obj.param.constant.constant = }, {obj.param.constant.readonly = }")
print(f"{obj.readonly = }, {obj.param.readonly.constant = }, {obj.param.readonly.readonly = }")

Output before:

obj.constant = 2, obj.param.constant.constant = False, obj.param.constant.readonly = False
obj.readonly = 3, obj.param.readonly.constant = False, obj.param.readonly.readonly = False

Output now:

obj.constant = 2, obj.param.constant.constant = True, obj.param.constant.readonly = False
obj.readonly = 3, obj.param.readonly.constant = True, obj.param.readonly.readonly = True

We should upstream this sort of utility to Param, maybe with some API improvements (e.g. should only act on readonly parameters, allow to specify a subset of parameters, make it available on the .param namespace).

@codecov

codecov Bot commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.29412% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.10%. Comparing base (d605c2b) to head (7b49b13).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
panel/util/parameters.py 85.29% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8371      +/-   ##
==========================================
- Coverage   86.10%   86.10%   -0.01%     
==========================================
  Files         349      349              
  Lines       54709    54747      +38     
==========================================
+ Hits        47108    47138      +30     
- Misses       7601     7609       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread panel/util/parameters.py
Comment thread panel/util/parameters.py
@philippjfr
philippjfr merged commit e7368ad into main Jan 21, 2026
37 of 39 checks passed
@philippjfr
philippjfr deleted the fix_edit_readonly branch January 21, 2026 15:22
@philippjfr philippjfr mentioned this pull request Jan 26, 2026
philippjfr added a commit that referenced this pull request Jan 28, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

edit_readonly context manager fails

2 participants