From f4e7fd51609740bc931b90995ddbcb6f94b67356 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:25:21 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.10 → v0.14.14](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.10...v0.14.14) - [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a78666c72b..cacb101dde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,12 +17,12 @@ repos: files: requirements-dev.txt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.10 + rev: v0.14.14 hooks: - id: ruff - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black language_version: python3 From 3791b858af974b81e0aa6e5dd2e7086b097cd867 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:25:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- folium/elements.py | 24 ++-- folium/features.py | 118 +++++------------- folium/folium.py | 12 +- folium/map.py | 60 +++------ folium/plugins/antpath.py | 6 +- folium/plugins/beautify_icon.py | 6 +- folium/plugins/boat_marker.py | 6 +- folium/plugins/draw.py | 6 +- folium/plugins/dual_map.py | 6 +- folium/plugins/encoded.py | 6 +- folium/plugins/fast_marker_cluster.py | 6 +- folium/plugins/feature_group_sub_group.py | 6 +- folium/plugins/float_image.py | 6 +- folium/plugins/fullscreen.py | 6 +- folium/plugins/geocoder.py | 6 +- folium/plugins/geoman.py | 6 +- folium/plugins/groupedlayercontrol.py | 6 +- folium/plugins/heat_map.py | 6 +- folium/plugins/heat_map_withtime.py | 6 +- folium/plugins/locate_control.py | 6 +- folium/plugins/marker_cluster.py | 6 +- folium/plugins/measure_control.py | 6 +- folium/plugins/minimap.py | 6 +- folium/plugins/mouse_position.py | 6 +- .../plugins/overlapping_marker_spiderfier.py | 6 +- folium/plugins/pattern.py | 12 +- folium/plugins/polyline_text_path.py | 6 +- folium/plugins/realtime.py | 6 +- folium/plugins/scroll_zoom_toggler.py | 6 +- folium/plugins/search.py | 6 +- folium/plugins/semicircle.py | 6 +- folium/plugins/side_by_side.py | 6 +- folium/plugins/tag_filter_button.py | 6 +- folium/plugins/terminator.py | 6 +- folium/plugins/time_slider_choropleth.py | 6 +- folium/plugins/timeline.py | 12 +- folium/plugins/timestamped_geo_json.py | 6 +- folium/plugins/timestamped_wmstilelayer.py | 6 +- folium/plugins/treelayercontrol.py | 6 +- folium/plugins/vectorgrid_protobuf.py | 6 +- folium/raster_layers.py | 24 ++-- folium/vector_layers.py | 30 ++--- tests/plugins/test_antpath.py | 6 +- tests/plugins/test_beautify_icon.py | 6 +- tests/plugins/test_boat_marker.py | 12 +- tests/plugins/test_dual_map.py | 6 +- tests/plugins/test_encoded.py | 12 +- tests/plugins/test_fast_marker_cluster.py | 6 +- tests/plugins/test_feature_group_sub_group.py | 6 +- tests/plugins/test_float_image.py | 12 +- tests/plugins/test_fullscreen.py | 6 +- tests/plugins/test_geoman.py | 6 +- tests/plugins/test_grouped_layer_control.py | 6 +- tests/plugins/test_heat_map.py | 6 +- tests/plugins/test_heat_map_withtime.py | 6 +- tests/plugins/test_marker_cluster.py | 6 +- tests/plugins/test_polyline_text_path.py | 6 +- tests/plugins/test_realtime.py | 6 +- tests/plugins/test_scroll_zoom_toggler.py | 18 +-- tests/plugins/test_semicircle.py | 12 +- tests/plugins/test_tag_filter_button.py | 6 +- tests/plugins/test_timeline.py | 6 +- tests/plugins/test_timestamped_geo_json.py | 6 +- .../modules/geoman_customizations.py | 13 +- tests/test_features.py | 12 +- tests/test_folium.py | 6 +- tests/test_raster_layers.py | 6 +- 67 files changed, 226 insertions(+), 469 deletions(-) diff --git a/folium/elements.py b/folium/elements.py index 327d92a9a5..88637fb1b6 100644 --- a/folium/elements.py +++ b/folium/elements.py @@ -122,16 +122,14 @@ class EventHandler(MacroElement): >>> g.add_child(EventHandler("mouseout", reset)) ''' - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {{ this._parent.get_name()}}.{{ this.method }}( {{ this.event|tojson}}, {{ this.handler.js_code }} ); {% endmacro %} - """ - ) + """) def __init__(self, event: str, handler: JsCode, once: bool = False): super().__init__() @@ -144,13 +142,11 @@ def __init__(self, event: str, handler: JsCode, once: bool = False): class ElementAddToElement(MacroElement): """Abstract class to add an element to another element.""" - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {{ this.element_name }}.addTo({{ this.element_parent_name }}); {% endmacro %} - """ - ) + """) def __init__(self, element_name: str, element_parent_name: str): super().__init__() @@ -161,13 +157,11 @@ def __init__(self, element_name: str, element_parent_name: str): class IncludeStatement(MacroElement): """Generate an include statement on a class.""" - _template = Template( - """ + _template = Template(""" {{ this.leaflet_class_name }}.include( {{ this.options | tojavascript }} ) - """ - ) + """) def __init__(self, leaflet_class_name: str, **kwargs): super().__init__() @@ -181,8 +175,7 @@ def render(self, *args, **kwargs): class MethodCall(MacroElement): """Abstract class to add an element to another element.""" - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {{ this.target }}.{{ this.method }}( {% for arg in this.args %} @@ -191,8 +184,7 @@ class MethodCall(MacroElement): {{ this.kwargs | tojavascript }} ); {% endmacro %} - """ - ) + """) def __init__(self, target: MacroElement, method: str, *args, **kwargs): super().__init__() diff --git a/folium/features.py b/folium/features.py index fac500af5a..c3c607a3e4 100644 --- a/folium/features.py +++ b/folium/features.py @@ -81,16 +81,14 @@ class RegularPolygonMarker(JSCSSMixin, Marker): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = new L.RegularPolygonMarker( {{ this.location|tojson }}, {{ this.options|tojavascript }} ).addTo({{ this._parent.get_name() }}); {% endmacro %} - """ - ) + """) default_js = [ ( @@ -191,24 +189,16 @@ def render(self, **kwargs): self.json = json.dumps(self.data) self._parent.html.add_child( - Element( - Template( - """ + Element(Template("""
- """ - ).render(this=self, kwargs=kwargs) - ), + """).render(this=self, kwargs=kwargs)), name=self.get_name(), ) self._parent.script.add_child( - Element( - Template( - """ + Element(Template(""" vega_parse({{this.json}},{{this.get_name()}}); - """ - ).render(this=self) - ), + """).render(this=self)), name=self.get_name(), ) @@ -218,9 +208,7 @@ def render(self, **kwargs): ), "You cannot render this Element if it is not in a Figure." figure.header.add_child( - Element( - Template( - """ + Element(Template(""" - """ - ).render(this=self, **kwargs) - ), + """).render(this=self, **kwargs)), name=self.get_name(), ) @@ -312,13 +298,9 @@ def render(self, **kwargs): ) parent.html.add_child( - Element( - Template( - """ + Element(Template(""" - """ - ).render(this=self, kwargs=kwargs) - ), + """).render(this=self, kwargs=kwargs)), name=self.get_name(), ) @@ -328,9 +310,7 @@ def render(self, **kwargs): ), "You cannot render this Element if it is not in a Figure." figure.header.add_child( - Element( - Template( - """ + Element(Template(""" - """ - ).render(this=self, **kwargs) - ), + """).render(this=self, **kwargs)), name=self.get_name(), ) @@ -440,23 +418,17 @@ def _embed_vegalite_v2(self, figure: Figure, parent: TypeContainer) -> None: def _vega_embed(self, parent: TypeContainer) -> None: parent.script.add_child( - Element( - Template( - """ + Element(Template(""" vegaEmbed({{this.get_name()}}, {{this.json}}) .then(function(result) {}) .catch(console.error); - """ - ).render(this=self) - ), + """).render(this=self)), name=self.get_name(), ) def _embed_vegalite_v1(self, figure: Figure, parent: TypeContainer) -> None: parent.script.add_child( - Element( - Template( - """ + Element(Template(""" var embedSpec = { mode: "vega-lite", spec: {{this.json}} @@ -464,9 +436,7 @@ def _embed_vegalite_v1(self, figure: Figure, parent: TypeContainer) -> None: vg.embed( {{this.get_name()}}, embedSpec, function(error, result) {} ); - """ - ).render(this=self) - ), + """).render(this=self)), name=self.get_name(), ) @@ -568,8 +538,7 @@ class GeoJson(Layer): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {%- if this.style %} function {{ this.get_name() }}_styler(feature) { @@ -693,8 +662,7 @@ class GeoJson(Layer): {%- endif %} {% endmacro %} - """ - ) # noqa + """) # noqa def __init__( self, @@ -1006,8 +974,7 @@ class TopoJson(JSCSSMixin, Layer): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }}_data = {{ this.data|tojson }}; var {{ this.get_name() }} = L.geoJson( @@ -1025,8 +992,7 @@ class TopoJson(JSCSSMixin, Layer): return feature.properties.style; }); {% endmacro %} - """ - ) # noqa + """) # noqa default_js = [ ( @@ -1247,9 +1213,7 @@ def render(self, **kwargs): value in keys ), f"The field {value} is not available in the data. Choose from: {keys}." figure.header.add_child( - Element( - Template( - """ + Element(Template(""" - """ - ).render(this=self) - ), + """).render(this=self)), name=self.get_name() + "tablestyle", ) @@ -1756,13 +1718,11 @@ class DivIcon(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.divIcon({{ this.options|tojavascript }}); {% endmacro %} - """ - ) # noqa + """) # noqa def __init__( self, @@ -1790,8 +1750,7 @@ class LatLngPopup(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{this.get_name()}} = L.popup(); function latLngPop(e) { @@ -1803,8 +1762,7 @@ class LatLngPopup(MacroElement): } {{this._parent.get_name()}}.on('click', latLngPop); {% endmacro %} - """ - ) # noqa + """) # noqa def __init__(self): super().__init__() @@ -1831,8 +1789,7 @@ class ClickForMarker(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} function newMarker(e){ var new_mark = L.marker().setLatLng(e.latlng).addTo({{this._parent.get_name()}}); @@ -1844,8 +1801,7 @@ class ClickForMarker(MacroElement): }; {{this._parent.get_name()}}.on('click', newMarker); {% endmacro %} - """ - ) # noqa + """) # noqa def __init__(self, popup: Union[IFrame, Html, str, None] = None): super().__init__() @@ -1875,8 +1831,7 @@ class ClickForLatLng(MacroElement): Whether there should be an alert when something has been copied to clipboard. """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} function getLatLng(e){ var lat = e.latlng.lat.toFixed(6), @@ -1887,8 +1842,7 @@ class ClickForLatLng(MacroElement): }; {{this._parent.get_name()}}.on('click', getLatLng); {% endmacro %} - """ - ) # noqa + """) # noqa def __init__(self, format_str: Optional[str] = None, alert: bool = True): super().__init__() @@ -1932,13 +1886,11 @@ class CustomIcon(Icon): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.icon({{ this.options|tojavascript }}); {% endmacro %} - """ - ) # noqa + """) # noqa def __init__( self, @@ -2058,8 +2010,7 @@ class Control(JSCSSMixin, Class): >>> Control("Zoom", position="topleft").add_to(m) """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = new L.Control.{{this._name}}( {% for arg in this.args %} @@ -2068,8 +2019,7 @@ class Control(JSCSSMixin, Class): {{ this.options|tojavascript }} ).addTo({{ this._parent.get_name() }}); {% endmacro %} - """ - ) + """) def __init__( self, diff --git a/folium/folium.py b/folium/folium.py index a85c2e42a0..aad9fed62a 100644 --- a/folium/folium.py +++ b/folium/folium.py @@ -64,14 +64,12 @@ class GlobalSwitches(Element): - _template = Template( - """ + _template = Template(""" - """ - ) + """) def __init__(self, no_touch=False, disable_3d=False): super().__init__() @@ -178,8 +176,7 @@ class Map(JSCSSMixin, Evented): """ # noqa - _template = Template( - """ + _template = Template(""" {% macro header(this, kwargs) %} @@ -252,8 +249,7 @@ class Map(JSCSSMixin, Evented): {%- endif %} {% endmacro %} - """ - ) + """) # use the module variables for backwards compatibility default_js = _default_js diff --git a/folium/map.py b/folium/map.py index dad78271e8..90fb205c23 100644 --- a/folium/map.py +++ b/folium/map.py @@ -163,15 +163,13 @@ class FeatureGroup(Layer): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.featureGroup( {{ this.options|tojavascript }} ); {% endmacro %} - """ - ) + """) def __init__( self, @@ -220,8 +218,7 @@ class LayerControl(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this,kwargs) %} var {{ this.get_name() }}_layers = { base_layers : { @@ -246,8 +243,7 @@ class LayerControl(MacroElement): {%- endif %} {% endmacro %} - """ - ) + """) def __init__( self, @@ -317,15 +313,13 @@ class Icon(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.AwesomeMarkers.icon( {{ this.options|tojavascript }} ); {% endmacro %} - """ - ) + """) color_options = { "red", "darkred", @@ -408,27 +402,23 @@ class Marker(MacroElement): ... ) """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.marker( {{ this.location|tojson }}, {{ this.options|tojavascript }} ).addTo({{ this._parent.get_name() }}); {% endmacro %} - """ - ) + """) class SetIcon(MacroElement): """Set the icon of a marker after both are created.""" - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {{ this.marker.get_name() }}.setIcon({{ this.icon.get_name() }}); {% endmacro %} - """ - ) + """) def __init__( self, marker: "Marker", icon: Union[Icon, "CustomIcon", "DivIcon"] @@ -515,8 +505,7 @@ class Popup(MacroElement): True only loads the Popup content when clicking on the Marker. """ - _template = Template( - """ + _template = Template(""" var {{this.get_name()}} = L.popup({{ this.options|tojavascript }}); {% for name, element in this.html._children.items() %} @@ -536,8 +525,7 @@ class Popup(MacroElement): {% for name, element in this.script._children.items() %} {{element.render()}} {% endfor %} - """ - ) # noqa + """) # noqa def __init__( self, @@ -612,8 +600,7 @@ class Tooltip(MacroElement): """ - _template = Template( - """ + _template = Template(""" {% macro script(this, kwargs) %} {{ this._parent.get_name() }}.bindTooltip( `