77import re
88import tempfile
99import uuid
10+ from collections .abc import Iterable , Iterator , Sequence
1011from contextlib import contextmanager
1112from typing import (
1213 TYPE_CHECKING ,
1314 Any ,
1415 Callable ,
15- Dict ,
16- Iterable ,
17- Iterator ,
18- List ,
1916 Literal ,
2017 Optional ,
21- Sequence ,
22- Tuple ,
23- Type ,
2418 Union ,
2519)
2620from urllib .parse import urlparse , uses_netloc , uses_params , uses_relative
5549TypePathOptions = Union [bool , str , float , None ]
5650
5751TypeBounds = Sequence [Sequence [float ]]
58- TypeBoundsReturn = List [ List [Optional [float ]]]
52+ TypeBoundsReturn = list [ list [Optional [float ]]]
5953
6054TypeContainer = Union [Figure , Div , "Popup" ]
6155TypePosition = Literal ["bottomright" , "bottomleft" , "topright" , "topleft" ]
6660_VALID_URLS .add ("data" )
6761
6862
69- def validate_location (location : Sequence [float ]) -> List [float ]:
63+ def validate_location (location : Sequence [float ]) -> list [float ]:
7064 """Validate a single lat/lon coordinate pair and convert to a list
7165
7266 Validate that location:
@@ -126,7 +120,7 @@ def _validate_locations_basics(locations: TypeMultiLine) -> None:
126120 raise ValueError ("Locations is empty." )
127121
128122
129- def validate_locations (locations : TypeLine ) -> List [ List [float ]]:
123+ def validate_locations (locations : TypeLine ) -> list [ list [float ]]:
130124 """Validate an iterable with lat/lon coordinate pairs."""
131125 locations = if_pandas_df_convert_to_numpy (locations )
132126 _validate_locations_basics (locations )
@@ -135,7 +129,7 @@ def validate_locations(locations: TypeLine) -> List[List[float]]:
135129
136130def validate_multi_locations (
137131 locations : TypeMultiLine ,
138- ) -> Union [List [ List [float ]], List [ List [ List [float ]]]]:
132+ ) -> Union [list [ list [float ]], list [ list [ list [float ]]]]:
139133 """Validate an iterable with possibly nested lists of coordinate pairs."""
140134 locations = if_pandas_df_convert_to_numpy (locations )
141135 _validate_locations_basics (locations )
@@ -215,7 +209,7 @@ def _is_url(url: str) -> bool:
215209
216210def mercator_transform (
217211 data : Any ,
218- lat_bounds : Tuple [float , float ],
212+ lat_bounds : tuple [float , float ],
219213 origin : str = "upper" ,
220214 height_out : Optional [int ] = None ,
221215) -> np .ndarray :
@@ -279,7 +273,7 @@ def mercator(x):
279273 return out
280274
281275
282- def iter_coords (obj : Any ) -> Iterator [Tuple [float , ...]]:
276+ def iter_coords (obj : Any ) -> Iterator [tuple [float , ...]]:
283277 """
284278 Returns all the coordinate tuples from a geometry or feature.
285279
@@ -313,13 +307,13 @@ def iter_coords(obj: Any) -> Iterator[Tuple[float, ...]]:
313307def get_bounds (
314308 locations : Any ,
315309 lonlat : bool = False ,
316- ) -> List [ List [Optional [float ]]]:
310+ ) -> list [ list [Optional [float ]]]:
317311 """
318312 Computes the bounds of the object in the form
319313 [[lat_min, lon_min], [lat_max, lon_max]]
320314
321315 """
322- bounds : List [ List [Optional [float ]]] = [[None , None ], [None , None ]]
316+ bounds : list [ list [Optional [float ]]] = [[None , None ], [None , None ]]
323317 for point in iter_coords (locations ):
324318 bounds = [
325319 [
@@ -397,22 +391,22 @@ def deep_copy(item_original: Element) -> Element:
397391 return item
398392
399393
400- def get_obj_in_upper_tree (element : Element , cls : Type ) -> Element :
394+ def get_obj_in_upper_tree (element : Element , cls : type ) -> Element :
401395 """Return the first object in the parent tree of class `cls`."""
402396 parent = element ._parent
403397 if parent is None :
404398 raise ValueError (f"The top of the tree was reached without finding a { cls } " )
405399 if not isinstance (parent , cls ):
406400 return get_obj_in_upper_tree (parent , cls )
407- return parent
401+ return parent # type: ignore
408402
409403
410- def parse_options (** kwargs : TypeJsonValue ) -> Dict [str , TypeJsonValueNoNone ]:
404+ def parse_options (** kwargs : TypeJsonValue ) -> dict [str , TypeJsonValueNoNone ]:
411405 """Return a dict with lower-camelcase keys and non-None values.."""
412406 return {camelize (key ): value for key , value in kwargs .items () if value is not None }
413407
414408
415- def remove_empty (** kwargs : TypeJsonValue ) -> Dict [str , TypeJsonValueNoNone ]:
409+ def remove_empty (** kwargs : TypeJsonValue ) -> dict [str , TypeJsonValueNoNone ]:
416410 """Return a dict without None values."""
417411 return {key : value for key , value in kwargs .items () if value is not None }
418412
0 commit comments