param icon indicating copy to clipboard operation
param copied to clipboard

Add LiteralRef wrapper to assign ref-like values without resolving

Open philippjfr opened this issue 4 months ago • 4 comments

  • [x] Implements https://github.com/holoviz/param/issues/1090
  • [x] Adds tests
  • [x] Add docs

philippjfr avatar Oct 29 '25 10:10 philippjfr

Codecov Report

:x: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review. :white_check_mark: Project coverage is 89.22%. Comparing base (f048bd3) to head (741f970). :warning: Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
param/parameterized.py 92.85% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1091      +/-   ##
==========================================
+ Coverage   89.15%   89.22%   +0.07%     
==========================================
  Files           9        9              
  Lines        4685     4726      +41     
==========================================
+ Hits         4177     4217      +40     
- Misses        508      509       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Oct 29 '25 10:10 codecov[bot]

This looks like a useful functionality for advanced users and libraries that integrate Param (like Panel, Lumen, etc.). A few comments:

  • I don't find raw or the other suggested names in the issue (constant, const, value) to be explicit enough and express that this is to wrap a reference so that it is not resolved eagerly by Param. How about Ref(<ref>, literal=True)? (I'm also fine with raw=True, or resolved=False). Or RefLiteral()?
  • I'm not convinced we need a utility like raw in addition to the class Raw (or a ref utility in addition to the Ref class I suggested above). It made sense with rx but this feature is clearly a simple wrapper class, that is going to be used sparingly for advanced cases (unlike rx that is for all users and can be used a lot in a module).
  • I'd prefer if this were not exposed in the top-level module, as it's a feature that I don't expect to be used that much.

maximlt avatar Oct 29 '25 15:10 maximlt

LiteralRef sounds fine, but is it guaranteed to be a reference? Isn't it just a lazy, unevaluated object in general? The concept seems to be the same as LISP's quote operator.

jbednar avatar Nov 05 '25 16:11 jbednar

Can you also add parameterized.LiteralRef to this file https://github.com/holoviz/param/blob/main/doc/reference/param/parameterized.md#helpers so that it's documented in the API?

maximlt avatar Nov 08 '25 09:11 maximlt