Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type hints after adding Branca type checking #2060

Merged
merged 13 commits into from
Dec 29, 2024
Prev Previous commit
Next Next commit
split TypeBounds in input and return types
  • Loading branch information
Conengmo committed Dec 29, 2024
commit 0764be3a2a59af2ce72ca15b0167359a90516d0e
4 changes: 2 additions & 2 deletions folium/features.py
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
none_max,
none_min,
remove_empty,
validate_locations,
validate_locations, TypeBoundsReturn,
)
from folium.vector_layers import Circle, CircleMarker, PolyLine, path_options

@@ -1046,7 +1046,7 @@ def render(self, **kwargs):
self.style_data()
super().render(**kwargs)

def get_bounds(self) -> List[List[float]]:
def get_bounds(self) -> TypeBoundsReturn:
"""
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]]
4 changes: 2 additions & 2 deletions folium/map.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
escape_backticks,
parse_options,
remove_empty,
validate_location,
validate_location, TypeBoundsReturn,
)

if TYPE_CHECKING:
@@ -396,7 +396,7 @@ def __init__(
tooltip if isinstance(tooltip, Tooltip) else Tooltip(str(tooltip))
)

def _get_self_bounds(self) -> TypeBounds:
def _get_self_bounds(self) -> TypeBoundsReturn:
"""Computes the bounds of the object itself.

Because a marker has only single coordinates, we repeat them.
6 changes: 3 additions & 3 deletions folium/raster_layers.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
image_to_url,
mercator_transform,
parse_options,
remove_empty,
remove_empty, TypeBoundsReturn,
)


@@ -344,7 +344,7 @@ def render(self, **kwargs):
Element(pixelated), name="leaflet-image-layer"
) # noqa

def _get_self_bounds(self) -> TypeBounds:
def _get_self_bounds(self) -> TypeBoundsReturn:
"""
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]].
@@ -411,7 +411,7 @@ def __init__(
self.bounds = bounds
self.options = remove_empty(autoplay=autoplay, loop=loop, **kwargs)

def _get_self_bounds(self) -> TypeBounds:
def _get_self_bounds(self) -> TypeBoundsReturn:
"""
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]]
3 changes: 2 additions & 1 deletion folium/utilities.py
Original file line number Diff line number Diff line change
@@ -49,7 +49,8 @@

TypePathOptions = Union[bool, str, float, None]

TypeBounds = List[List[Optional[float]]]
TypeBounds = Sequence[Sequence[float]]
TypeBoundsReturn = List[List[Optional[float]]]


_VALID_URLS = set(uses_relative + uses_netloc + uses_params)