77import json
88import operator
99import warnings
10- from collections .abc import Iterable , Sequence
10+ from collections .abc import Callable , Iterable , Sequence
1111from typing import (
1212 Any ,
13- Callable ,
1413 Optional ,
1514 Union ,
1615 get_args ,
@@ -103,8 +102,8 @@ def __init__(
103102 number_of_sides : int = 4 ,
104103 rotation : int = 0 ,
105104 radius : int = 15 ,
106- popup : Union [ Popup , str , None ] = None ,
107- tooltip : Union [ Tooltip , str , None ] = None ,
105+ popup : Popup | str | None = None ,
106+ tooltip : Tooltip | str | None = None ,
108107 ** kwargs : TypePathOptions ,
109108 ):
110109 super ().__init__ (location , popup = popup , tooltip = tooltip )
@@ -159,10 +158,10 @@ class Vega(JSCSSMixin):
159158 def __init__ (
160159 self ,
161160 data : Any ,
162- width : Union [ int , str , None ] = None ,
163- height : Union [ int , str , None ] = None ,
164- left : Union [ int , str ] = "0%" ,
165- top : Union [ int , str ] = "0%" ,
161+ width : int | str | None = None ,
162+ height : int | str | None = None ,
163+ left : int | str = "0%" ,
164+ top : int | str = "0%" ,
166165 position : str = "relative" ,
167166 ):
168167 super ().__init__ ()
@@ -264,10 +263,10 @@ class VegaLite(MacroElement):
264263 def __init__ (
265264 self ,
266265 data : Any ,
267- width : Union [ int , str , None ] = None ,
268- height : Union [ int , str , None ] = None ,
269- left : Union [ int , str ] = "0%" ,
270- top : Union [ int , str ] = "0%" ,
266+ width : int | str | None = None ,
267+ height : int | str | None = None ,
268+ left : int | str = "0%" ,
269+ top : int | str = "0%" ,
271270 position : str = "relative" ,
272271 ):
273272 super (self .__class__ , self ).__init__ ()
@@ -338,7 +337,7 @@ def render(self, **kwargs):
338337 embed_vegalite (figure = figure , parent = parent )
339338
340339 @property
341- def vegalite_major_version (self ) -> Optional [ int ] :
340+ def vegalite_major_version (self ) -> int | None :
342341 if "$schema" not in self .data :
343342 return None
344343
@@ -678,26 +677,26 @@ class GeoJson(Layer):
678677 def __init__ (
679678 self ,
680679 data : Any ,
681- style_function : Optional [ Callable ] = None ,
682- highlight_function : Optional [ Callable ] = None ,
680+ style_function : Callable | None = None ,
681+ highlight_function : Callable | None = None ,
683682 popup_keep_highlighted : bool = False ,
684- name : Optional [ str ] = None ,
683+ name : str | None = None ,
685684 overlay : bool = True ,
686685 control : bool = True ,
687686 show : bool = True ,
688- smooth_factor : Optional [ float ] = None ,
687+ smooth_factor : float | None = None ,
689688 tooltip : Union [str , Tooltip , "GeoJsonTooltip" , None ] = None ,
690689 embed : bool = True ,
691690 popup : Optional ["GeoJsonPopup" ] = None ,
692691 zoom_on_click : bool = False ,
693- on_each_feature : Optional [ JsCode ] = None ,
694- marker : Union [ Circle , CircleMarker , Marker , None ] = None ,
692+ on_each_feature : JsCode | None = None ,
693+ marker : Circle | CircleMarker | Marker | None = None ,
695694 ** kwargs : Any ,
696695 ):
697696 super ().__init__ (name = name , overlay = overlay , control = control , show = show )
698697 self ._name = "GeoJson"
699698 self .embed = embed
700- self .embed_link : Optional [ str ] = None
699+ self .embed_link : str | None = None
701700 self .json = None
702701 self .parent_map = None
703702 self .smooth_factor = smooth_factor
@@ -845,7 +844,7 @@ def find_identifier(self) -> str:
845844 "field to your geojson data or set `embed=True`. "
846845 )
847846
848- def _get_self_bounds (self ) -> list [list [Optional [ float ] ]]:
847+ def _get_self_bounds (self ) -> list [list [float | None ]]:
849848 """
850849 Computes the bounds of the object itself (not including it's children)
851850 in the form [[lat_min, lon_min], [lat_max, lon_max]].
@@ -865,7 +864,7 @@ def render(self, **kwargs):
865864 super ().render ()
866865
867866
868- TypeStyleMapping = dict [str , Union [ str , list [Union [ str , int ]] ]]
867+ TypeStyleMapping = dict [str , str | list [str | int ]]
869868
870869
871870class GeoJsonStyleMapper :
@@ -912,7 +911,7 @@ def _create_mapping(self, func: Callable, switch: str) -> TypeStyleMapping:
912911 self ._set_default_key (mapping )
913912 return mapping
914913
915- def get_feature_id (self , feature : dict ) -> Union [ str , int ] :
914+ def get_feature_id (self , feature : dict ) -> str | int :
916915 """Return a value identifying the feature."""
917916 prefix = "feature.properties["
918917 if self .feature_identifier .startswith (prefix ):
@@ -1025,13 +1024,13 @@ def __init__(
10251024 self ,
10261025 data : Any ,
10271026 object_path : str ,
1028- style_function : Optional [ Callable ] = None ,
1029- name : Optional [ str ] = None ,
1027+ style_function : Callable | None = None ,
1028+ name : str | None = None ,
10301029 overlay : bool = True ,
10311030 control : bool = True ,
10321031 show : bool = True ,
1033- smooth_factor : Optional [ float ] = None ,
1034- tooltip : Union [ str , Tooltip , None ] = None ,
1032+ smooth_factor : float | None = None ,
1033+ tooltip : str | Tooltip | None = None ,
10351034 ):
10361035 super ().__init__ (name = name , overlay = overlay , control = control , show = show )
10371036 self ._name = "TopoJson"
@@ -1161,10 +1160,10 @@ class GeoJsonDetail(MacroElement):
11611160 def __init__ (
11621161 self ,
11631162 fields : Sequence [str ],
1164- aliases : Optional [ Sequence [str ]] = None ,
1163+ aliases : Sequence [str ] | None = None ,
11651164 labels : bool = True ,
11661165 localize : bool = False ,
1167- style : Optional [ str ] = None ,
1166+ style : str | None = None ,
11681167 class_name : str = "geojsondetail" ,
11691168 ):
11701169 super ().__init__ ()
@@ -1311,10 +1310,10 @@ class GeoJsonTooltip(GeoJsonDetail):
13111310 def __init__ (
13121311 self ,
13131312 fields : Sequence [str ],
1314- aliases : Optional [ Sequence [str ]] = None ,
1313+ aliases : Sequence [str ] | None = None ,
13151314 labels : bool = True ,
13161315 localize : bool = False ,
1317- style : Optional [ str ] = None ,
1316+ style : str | None = None ,
13181317 class_name : str = "foliumtooltip" ,
13191318 sticky : bool = True ,
13201319 ** kwargs : TypeJsonValue ,
@@ -1379,7 +1378,7 @@ class GeoJsonPopup(GeoJsonDetail):
13791378 def __init__ (
13801379 self ,
13811380 fields : Sequence [str ],
1382- aliases : Optional [ Sequence [str ]] = None ,
1381+ aliases : Sequence [str ] | None = None ,
13831382 labels : bool = True ,
13841383 style : str = "margin: auto;" ,
13851384 class_name : str = "foliumpopup" ,
@@ -1520,24 +1519,24 @@ class Choropleth(FeatureGroup):
15201519 def __init__ (
15211520 self ,
15221521 geo_data : Any ,
1523- data : Optional [ Any ] = None ,
1524- columns : Optional [ Sequence [Any ]] = None ,
1525- key_on : Optional [ str ] = None ,
1526- bins : Union [ int , Sequence [float ] ] = 6 ,
1527- fill_color : Optional [ str ] = None ,
1522+ data : Any | None = None ,
1523+ columns : Sequence [Any ] | None = None ,
1524+ key_on : str | None = None ,
1525+ bins : int | Sequence [float ] = 6 ,
1526+ fill_color : str | None = None ,
15281527 nan_fill_color : str = "black" ,
15291528 fill_opacity : float = 0.6 ,
1530- nan_fill_opacity : Optional [ float ] = None ,
1529+ nan_fill_opacity : float | None = None ,
15311530 line_color : str = "black" ,
15321531 line_weight : float = 1 ,
15331532 line_opacity : float = 1 ,
1534- name : Optional [ str ] = None ,
1533+ name : str | None = None ,
15351534 legend_name : str = "" ,
15361535 overlay : bool = True ,
15371536 control : bool = True ,
15381537 show : bool = True ,
1539- topojson : Optional [ str ] = None ,
1540- smooth_factor : Optional [ float ] = None ,
1538+ topojson : str | None = None ,
1539+ smooth_factor : float | None = None ,
15411540 highlight : bool = False ,
15421541 use_jenks : bool = False ,
15431542 ** kwargs ,
@@ -1668,7 +1667,7 @@ def highlight_function(x):
16681667 return {"weight" : line_weight + 2 , "fillOpacity" : fill_opacity + 0.2 }
16691668
16701669 if topojson :
1671- self .geojson : Union [ TopoJson , GeoJson ] = TopoJson (
1670+ self .geojson : TopoJson | GeoJson = TopoJson (
16721671 geo_data ,
16731672 topojson ,
16741673 style_function = style_function ,
@@ -1687,7 +1686,7 @@ def highlight_function(x):
16871686 self .add_child (self .color_scale )
16881687
16891688 @classmethod
1690- def _get_by_key (cls , obj : Union [ dict , list ] , key : str ) -> Union [ float , str , None ] :
1689+ def _get_by_key (cls , obj : dict | list , key : str ) -> float | str | None :
16911690 key_parts = key .split ("." )
16921691 first_key_part = key_parts [0 ]
16931692 if first_key_part .isdigit ():
@@ -1748,10 +1747,10 @@ class DivIcon(MacroElement):
17481747
17491748 def __init__ (
17501749 self ,
1751- html : Optional [ str ] = None ,
1752- icon_size : Optional [ tuple [int , int ]] = None ,
1753- icon_anchor : Optional [ tuple [int , int ]] = None ,
1754- popup_anchor : Optional [ tuple [int , int ]] = None ,
1750+ html : str | None = None ,
1751+ icon_size : tuple [int , int ] | None = None ,
1752+ icon_anchor : tuple [int , int ] | None = None ,
1753+ popup_anchor : tuple [int , int ] | None = None ,
17551754 class_name : str = "empty" ,
17561755 ):
17571756 super ().__init__ ()
@@ -1825,7 +1824,7 @@ class ClickForMarker(MacroElement):
18251824 {% endmacro %}
18261825 """ ) # noqa
18271826
1828- def __init__ (self , popup : Union [ IFrame , Html , str , None ] = None ):
1827+ def __init__ (self , popup : IFrame | Html | str | None = None ):
18291828 super ().__init__ ()
18301829 self ._name = "ClickForMarker"
18311830
@@ -1866,7 +1865,7 @@ class ClickForLatLng(MacroElement):
18661865 {% endmacro %}
18671866 """ ) # noqa
18681867
1869- def __init__ (self , format_str : Optional [ str ] = None , alert : bool = True ):
1868+ def __init__ (self , format_str : str | None = None , alert : bool = True ):
18701869 super ().__init__ ()
18711870 self ._name = "ClickForLatLng"
18721871 self .format_str = format_str or 'lat + "," + lng'
@@ -1917,12 +1916,12 @@ class CustomIcon(Icon):
19171916 def __init__ (
19181917 self ,
19191918 icon_image : Any ,
1920- icon_size : Optional [ tuple [int , int ]] = None ,
1921- icon_anchor : Optional [ tuple [int , int ]] = None ,
1919+ icon_size : tuple [int , int ] | None = None ,
1920+ icon_anchor : tuple [int , int ] | None = None ,
19221921 shadow_image : Any = None ,
1923- shadow_size : Optional [ tuple [int , int ]] = None ,
1924- shadow_anchor : Optional [ tuple [int , int ]] = None ,
1925- popup_anchor : Optional [ tuple [int , int ]] = None ,
1922+ shadow_size : tuple [int , int ] | None = None ,
1923+ shadow_anchor : tuple [int , int ] | None = None ,
1924+ popup_anchor : tuple [int , int ] | None = None ,
19261925 ):
19271926 super (Icon , self ).__init__ ()
19281927 self ._name = "icon"
@@ -1970,10 +1969,10 @@ def __init__(
19701969 self ,
19711970 positions : TypeLine ,
19721971 colors : Iterable [float ],
1973- colormap : Union [ ColorMap , Sequence [Any ], None ] = None ,
1972+ colormap : ColorMap | Sequence [Any ] | None = None ,
19741973 nb_steps : int = 12 ,
1975- weight : Optional [ int ] = None ,
1976- opacity : Optional [ float ] = None ,
1974+ weight : int | None = None ,
1975+ opacity : float | None = None ,
19771976 ** kwargs : Any ,
19781977 ):
19791978 super ().__init__ (** kwargs )
@@ -2045,9 +2044,9 @@ class Control(JSCSSMixin, Class):
20452044
20462045 def __init__ (
20472046 self ,
2048- control : Optional [ str ] = None ,
2047+ control : str | None = None ,
20492048 * args ,
2050- position : Optional [ TypePosition ] = None ,
2049+ position : TypePosition | None = None ,
20512050 ** kwargs ,
20522051 ):
20532052 super ().__init__ ()
0 commit comments