A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: date range not defaulting to `start` and `stop` (#3651)
Hofer-Julian5ead64eac2e1
diff --git a/marimo/_plugins/ui/_impl/dates.py b/marimo/_plugins/ui/_impl/dates.pyindex 6e1648b4d0..01357a8d19 100644--- a/marimo/_plugins/ui/_impl/dates.py+++ b/marimo/_plugins/ui/_impl/dates.py@@ -385,7 +385,10 @@ class date_range(UIElement[Tuple[str, str], Tuple[dt.date, dt.date]]):)if value is None:- value = (dt.date.today(), dt.date.today())+ if start is None or stop is None:+ value = (dt.date.today(), dt.date.today())+ else:+ value = (start, stop)elif (value[0] < self._startor value[1] > self._stopdiff --git a/tests/_plugins/ui/_impl/test_dates.py b/tests/_plugins/ui/_impl/test_dates.pyindex 89495d3840..11c1d21b74 100644--- a/tests/_plugins/ui/_impl/test_dates.py+++ b/tests/_plugins/ui/_impl/test_dates.py@@ -75,6 +75,15 @@ def test_date_range() -> None:assert dr.value == (datetime.date(2024, 2, 1), datetime.date(2024, 2, 29))# Test with start and stop+ dr = ui.date_range(+ start="2024-01-01",+ stop="2024-12-31",+ )+ assert dr.start == datetime.date(2024, 1, 1)+ assert dr.stop == datetime.date(2024, 12, 31)+ assert dr.value == (dr.start, dr.stop)++ # Test with start, stop and valuedr = ui.date_range(value=("2024-03-01", "2024-03-15"),start="2024-01-01",