Skip to content

fix: handle value=None in DateRangeSlider._sync_values - #8901

Merged
philippjfr merged 2 commits into
holoviz:mainfrom
Jojoussef:fix/8871-daterangeslider-none-value
Oct 23, 2026
Merged

philippjfr merged 2 commits into
holoviz:mainfrom
Jojoussef:fix/8871-daterangeslider-none-value

Conversation

@Jojoussef

Copy link
Copy Markdown
Contributor

Description

Assigning DateRangeSlider.value = None raises a TypeError in _sync_values (panel/widgets/slider.py:785):

vs, ve = self.value
TypeError: cannot unpack non-iterable NoneType object

DateRangeSlider initializes with value = None when bounds are not yet supplied, and _process_param_change already handles value is None by deleting 'value' from model properties before sending them to Bokeh. However, _sync_values attempted to unpack self.value unconditionally whenever value changed.

This patch updates _sync_values to check whether self.value is None. When None, it updates value_start and value_end to None. When non-None, it unpacks the tuple as before. It also removes the unused allow_None=False argument on the param.DateRange declaration, which was overridden by Param because default=None.

Fixes #8871

I added two unit regression tests to panel/tests/widgets/test_slider.py:

  • test_date_range_slider_value_none: verifies setting DateRangeSlider.value = None updates value_start and value_end to None without raising, and allows subsequent tuple re-assignment.
  • test_datetime_range_slider_value_none: verifies the same behavior on DatetimeRangeSlider.

Both tests fail with TypeError on unchanged main and pass with this change. The complete slider test suite (pytest panel/tests/widgets/test_slider.py) passes with 84 passing tests.

Checklist

  • Tests added and are passing

@philippjfr philippjfr mentioned this pull request Oct 23, 2026
2 tasks done
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.71%. Comparing base (cd9f377) to head (e93cb1b).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8901      +/-   ##
==========================================
- Coverage   89.79%   89.71%   -0.09%     
==========================================
  Files         406      406              
  Lines       69094    69118      +24     
==========================================
- Hits        62046    62011      -35     
- Misses       7048     7107      +59     

☔ View full report in Codecov by Harness.
📢 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.

@philippjfr
philippjfr merged commit cd9b24b into holoviz:main Oct 23, 2026
20 checks passed
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.

DateRangeSlider accepts value=None and then raises in _sync_values

2 participants