Add LiteralRef wrapper to assign ref-like values without resolving
- [x] Implements https://github.com/holoviz/param/issues/1090
- [x] Adds tests
- [x] Add docs
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.
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 withraw=True, orresolved=False). OrRefLiteral()? - I'm not convinced we need a utility like
rawin addition to the classRaw(or arefutility in addition to theRefclass I suggested above). It made sense withrxbut this feature is clearly a simple wrapper class, that is going to be used sparingly for advanced cases (unlikerxthat 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.
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.
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?