Skip to content

Commit e157904

Browse files
committed
Fix geopandas import check
1 parent 15945d2 commit e157904

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

maplibre/map.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class MapOptions(MapLibreBaseModel):
5151
See [MapOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions) for details.
5252
"""
5353

54-
model_config = ConfigDict(validate_assignment=True, extra="forbid", use_enum_values=False)
54+
model_config = ConfigDict(
55+
validate_assignment=True, extra="forbid", use_enum_values=False
56+
)
5557

5658
antialias: bool = None
5759
attribution_control: bool = Field(None, serialization_alias="attributionControl")
@@ -75,7 +77,9 @@ class MapOptions(MapLibreBaseModel):
7577
min_zoom: int = Field(None, serialization_alias="minZoom")
7678
pitch: Union[int, float] = None
7779
scroll_zoom: bool = Field(None, serialization_alias="scrollZoom")
78-
style: Union[str, Carto, MapTiler, OpenFreeMap, dict, Basemap] = Field(Carto.DARK_MATTER, validate_default=True)
80+
style: Union[str, Carto, MapTiler, OpenFreeMap, dict, Basemap] = Field(
81+
Carto.DARK_MATTER, validate_default=True
82+
)
7983
zoom: Union[int, float] = None
8084

8185
@field_validator("style")
@@ -208,7 +212,7 @@ def add_source(self, id: str, source: Source | dict | gpd.GeoDataFrame) -> None:
208212
id (str): The unique ID of the source.
209213
source (Source | dict | gpd.GeoDataFrame): The source to be added to the map.
210214
"""
211-
if GEOPANDAS is not None and isinstance(source, gpd.GeoDataFrame):
215+
if GEOPANDAS and isinstance(source, gpd.GeoDataFrame):
212216
source = SimpleFeatures(source).to_source()
213217

214218
if isinstance(source, Source):
@@ -257,7 +261,9 @@ def add_popup(self, layer_id: str, prop: str = None, template: str = None) -> No
257261
"""
258262
self.add_call("addPopup", layer_id, prop, template)
259263

260-
def add_tooltip(self, layer_id: str, prop: str = None, template: str = None) -> None:
264+
def add_tooltip(
265+
self, layer_id: str, prop: str = None, template: str = None
266+
) -> None:
261267
"""Add a tooltip to the map
262268
263269
Args:
@@ -337,7 +343,9 @@ def fit_bounds(
337343

338344
self.add_call("fitBounds", bounds, kwargs)
339345

340-
def set_projection(self, type: str | ProjectionType | list = ProjectionType.GLOBE) -> None:
346+
def set_projection(
347+
self, type: str | ProjectionType | list = ProjectionType.GLOBE
348+
) -> None:
341349
"""Set the projection of the map"""
342350
self.add_call("setProjection", dict(type=type))
343351

@@ -378,12 +386,18 @@ def to_html(self, title: str = "My Awesome Map", **kwargs) -> str:
378386
"""
379387
js_lib = read_internal_file("srcjs", "pywidget.js")
380388
js_snippet = Template(js_template).render(data=json.dumps(self.to_dict()))
381-
css_file = "ipywidget.maplibre-geocoder.css" if self._geocoder_type == GeocoderType.MAPLIBRE else "pywidget.css"
389+
css_file = (
390+
"ipywidget.maplibre-geocoder.css"
391+
if self._geocoder_type == GeocoderType.MAPLIBRE
392+
else "pywidget.css"
393+
)
382394
css = read_internal_file("srcjs", css_file)
383395
headers = [f"<style>{css}</style>"]
384396

385397
# Deck.GL headers
386-
add_deckgl_headers = "addDeckOverlay" in [item[0] for item in self._message_queue]
398+
add_deckgl_headers = "addDeckOverlay" in [
399+
item[0] for item in self._message_queue
400+
]
387401
# TODO: Set version in constants
388402
deckgl_headers = (
389403
[
@@ -397,7 +411,9 @@ def to_html(self, title: str = "My Awesome Map", **kwargs) -> str:
397411
)
398412

399413
# Mapbox Draw headers
400-
add_mapbox_draw_headers = "addMapboxDraw" in [item[0] for item in self._message_queue]
414+
add_mapbox_draw_headers = "addMapboxDraw" in [
415+
item[0] for item in self._message_queue
416+
]
401417
# TODO: Set version in constants
402418
mapbox_draw_headers = (
403419
[
@@ -425,7 +441,9 @@ def save(self, filename: str = None, preview=True, **kwargs):
425441
# -------------------------
426442
# Plugins
427443
# -------------------------
428-
def add_deck_layers(self, layers: list[dict | pdk.Layer], tooltip: str | dict = None) -> None:
444+
def add_deck_layers(
445+
self, layers: list[dict | pdk.Layer], tooltip: str | dict = None
446+
) -> None:
429447
"""Add Deck.GL layers to the layer stack
430448
431449
Args:
@@ -436,7 +454,9 @@ def add_deck_layers(self, layers: list[dict | pdk.Layer], tooltip: str | dict =
436454
layers = parse_deck_layers(layers)
437455
self.add_call("addDeckOverlay", layers, tooltip)
438456

439-
def set_deck_layers(self, layers: list[dict | pdk.Layer], tooltip: str | dict = None) -> None:
457+
def set_deck_layers(
458+
self, layers: list[dict | pdk.Layer], tooltip: str | dict = None
459+
) -> None:
440460
"""Update Deck.GL layers
441461
442462
Args:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "maplibre"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
description = "Python bindings for MapLibre GL JS"
55
authors = ["Stefan Kuethe <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)