From e88a213f5b73ce903700d0ad863b3cbbcb5adeee Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 20 Oct 2025 19:52:38 -0400 Subject: [PATCH 1/2] fix: Ensure that the default value of `Map.basemap` is `MaplibreBasemap` if no value of `basemap` was passed. --- lonboard/_map.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lonboard/_map.py b/lonboard/_map.py index b99e8520..e86ea75b 100644 --- a/lonboard/_map.py +++ b/lonboard/_map.py @@ -221,6 +221,9 @@ def on_click(self, callback: Callable, *, remove: bool = False) -> None: basemap: t.Instance[MaplibreBasemap | None] = t.Instance( MaplibreBasemap, + # If both `args` and `kw` are None, then the default value is None. + # Set empty kw so that the default is MaplibreBasemap() with default params + kw={}, allow_none=True, ).tag( sync=True, From f27aeac8f7af3ac86136a53892de189a557fac47 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 20 Oct 2025 19:53:24 -0400 Subject: [PATCH 2/2] add test --- tests/test_map.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_map.py b/tests/test_map.py index 4dee1d30..4e6970b0 100644 --- a/tests/test_map.py +++ b/tests/test_map.py @@ -2,6 +2,7 @@ from traitlets import TraitError from lonboard import Map, ScatterplotLayer, SolidPolygonLayer +from lonboard.basemap import MaplibreBasemap def test_map_fails_with_unexpected_argument(): @@ -38,3 +39,13 @@ def allow_single_layer(): def test_map_basemap_non_url(): with pytest.raises(TraitError, match=r"expected to be a HTTP\(s\) URL"): _m = Map([], basemap_style="hello world") + + +def test_map_default_basemap(): + m = Map([]) + assert isinstance(m.basemap, MaplibreBasemap), ( + "Default basemap should be MaplibreBasemap" + ) + + assert m.basemap.mode == MaplibreBasemap().mode, "Should match default parameters" + assert m.basemap.style == MaplibreBasemap().style, "Should match default parameters"