Skip to content

Conversation

@philippjfr
Copy link
Member

@philippjfr philippjfr commented Oct 29, 2025

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

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

Files with missing lines Patch % Lines
param/parameterized.py 92.85% 1 Missing ⚠️
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     

☔ 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.

@maximlt
Copy link
Member

maximlt commented Oct 29, 2025

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.

@philippjfr philippjfr requested a review from maximlt November 5, 2025 11:42
@philippjfr philippjfr changed the title Add raw wrapper to assign ref-like values without resolving Add LiteralRef wrapper to assign ref-like values without resolving Nov 5, 2025
Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I missed until now that the wrapper was just transient. I think I stopped at "without resolving". I'm okay with that but was just wondering, @philippjfr is unwrapping more convenient than keeping it as-is? Unless you already know the Parameter is holding a literal ref, I guess you need a is_ref function? While if it's still wrapped as a LiteralRef, it's just an isinstance call?

Comment on lines +175 to +176
Example
-------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Example
-------
Examples
--------

"outputs": [],
"source": [
"class Example(param.Parameterized):\n",
" value = param.Parameter(allow_refs=True)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to avoid the possible confusion that this would only work with the base Parameter.

Suggested change
" value = param.Parameter(allow_refs=True)\n",
" value = param.String(allow_refs=True)\n",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this will error, because the ref value (i.e. the Parameter instance) is not a string.

"id": "481223e8-750e-41b4-8376-63381b2012c6",
"metadata": {},
"source": [
"#### Key points\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"#### Key points\n",
"### Key points\n",

"- The wrapper is transient: it's unwrapped at assignment time; the stored value is the inner ref object.\n",
"- No subscription, no evaluation, no resolution occurs during assignment.\n",
"\n",
"#### When to use LiteralRef\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"#### When to use LiteralRef\n",
"### When to use LiteralRef\n",

@jbednar
Copy link
Member

jbednar commented Nov 5, 2025

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.

@maximlt
Copy link
Member

maximlt commented Nov 8, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants