From 4fe30375f36b4dbca0aebc5f2c6f12b25ae2d816 Mon Sep 17 00:00:00 2001 From: Iain Date: Thu, 5 Nov 2026 21:09:17 +0000 Subject: [PATCH] Keep Control's positional arguments when position is set The position check assigned get_args(TypePosition) to args, which is also the name of the *args parameter, so self.args became the four corner names. Leaflet then read the first corner name as the options object and ignored position and every other option. --- folium/features.py | 4 ++-- tests/test_folium.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/folium/features.py b/folium/features.py index 587f5e053b..43b1516180 100644 --- a/folium/features.py +++ b/folium/features.py @@ -2056,8 +2056,8 @@ def __init__( if position is not None: position = position.lower() # type: ignore - if position not in (args := get_args(TypePosition)): - raise TypeError(f"position must be one of {args}") + if position not in (positions := get_args(TypePosition)): + raise TypeError(f"position must be one of {positions}") kwargs["position"] = position self.args = args diff --git a/tests/test_folium.py b/tests/test_folium.py index 7679140c1e..36a8298c4c 100644 --- a/tests/test_folium.py +++ b/tests/test_folium.py @@ -558,3 +558,7 @@ def test_control_typecheck(self): assert "position must be one of ('bottomright', 'bottomleft'" in str( excinfo.value ) + + def test_control_keeps_args_with_position(self): + control = folium.Control("MiniMap", "layer", position="bottomright") + assert control.args == ("layer",)