Skip to content

Commit

Permalink
chore: update typehinting on dataset (#2092)
Browse files Browse the repository at this point in the history
* chore: update typehinting on `dataset`

Signed-off-by: slowy07 <[email protected]>

* chore: update typehinting-support on `deck`

Signed-off-by: slowy07 <[email protected]>

---------

Signed-off-by: slowy07 <[email protected]>
Signed-off-by: slowy07 <[email protected]>
  • Loading branch information
slowy07 authored Jul 23, 2024
1 parent 9995f26 commit 123d486
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
18 changes: 9 additions & 9 deletions geemap/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .common import download_from_url, ee_data_html, search_ee_data


def get_data_csv():
def get_data_csv() -> str:
"""Gets the file path to the CSV file containing the information about the Earth Engine Data Catalog.
Returns:
Expand All @@ -31,7 +31,7 @@ def get_data_csv():
return data_csv


def update_data_list(out_dir="."):
def update_data_list(out_dir=".") -> None:
"""Updates the Earth Engine Data Catalog dataset list.
Args:
Expand Down Expand Up @@ -68,7 +68,7 @@ def update_data_list(out_dir="."):
raise Exception(e)


def get_data_list():
def get_data_list() -> list:
"""Gets a list of Earth Engine datasets.
Returns:
Expand All @@ -82,7 +82,7 @@ def get_data_list():
return datasets + extra_datasets + community_datasets


def get_geemap_data_list():
def get_geemap_data_list() -> list:
"""Gets the list of the public datasets from GEE users.
Returns:
Expand All @@ -102,7 +102,7 @@ def get_geemap_data_list():
return extra_datasets


def get_community_data_list():
def get_community_data_list() -> list:
"""Gets the list community datasets
from https://github.com/samapriya/awesome-gee-community-datasets/blob/master/community_datasets.json
Expand All @@ -113,7 +113,7 @@ def get_community_data_list():
return [collection.get("id", None) for collection in collections]


def get_ee_stac_list():
def get_ee_stac_list() -> list:
"""Gets the STAC list of the Earth Engine Data Catalog.
Raises:
Expand All @@ -136,7 +136,7 @@ def get_ee_stac_list():
raise Exception(e)


def merge_dict(dict1, dict2):
def merge_dict(dict1: dict, dict2: dict) -> dict:
"""Merges two nested dictionaries.
Args:
Expand All @@ -149,7 +149,7 @@ def merge_dict(dict1, dict2):
return {**dict1, **dict2}


def get_data_dict():
def get_data_dict() -> dict:
"""Gets the Earth Engine Data Catalog as a nested dictionary.
Returns:
Expand All @@ -173,7 +173,7 @@ def get_data_dict():
return data_dict


def get_metadata(asset_id, source="ee"):
def get_metadata(asset_id: str, source: str = "ee") -> dict:
"""Gets metadata about an Earth Engine asset.
Args:
Expand Down
43 changes: 36 additions & 7 deletions geemap/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .osm import *
from .geemap import basemaps
from . import examples
from typing import Optional

try:
import pydeck as pdk
Expand Down Expand Up @@ -185,7 +186,7 @@ def add_ee_layer(

addLayer = add_ee_layer

def add_basemap(self, basemap="HYBRID"):
def add_basemap(self, basemap: str = "HYBRID") -> None:
"""Adds a basemap to the map.
Args:
Expand Down Expand Up @@ -224,7 +225,13 @@ def add_basemap(self, basemap="HYBRID"):
)
)

def add_gdf(self, gdf, layer_name=None, random_color_column=None, **kwargs):
def add_gdf(
self,
gdf,
layer_name: Optional[str] = None,
random_color_column: Optional[str] = None,
**kwargs,
) -> None:
"""Adds a GeoPandas GeoDataFrame to the map.
Args:
Expand Down Expand Up @@ -288,7 +295,13 @@ def add_gdf(self, gdf, layer_name=None, random_color_column=None, **kwargs):
except Exception as e:
raise Exception(e)

def add_vector(self, filename, layer_name=None, random_color_column=None, **kwargs):
def add_vector(
self,
filename: str,
layer_name: Optional[str] = None,
random_color_column: Optional[str] = None,
**kwargs,
) -> None:
"""Adds a vector file to the map.
Args:
Expand Down Expand Up @@ -320,8 +333,12 @@ def add_vector(self, filename, layer_name=None, random_color_column=None, **kwar
raise Exception(e)

def add_geojson(
self, filename, layer_name=None, random_color_column=None, **kwargs
):
self,
filename: str,
layer_name: Optional[str] = None,
random_color_column: Optional[str] = None,
**kwargs,
) -> None:
"""Adds a GeoJSON file to the map.
Args:
Expand All @@ -334,7 +351,13 @@ def add_geojson(
"""
self.add_vector(filename, layer_name, random_color_column, **kwargs)

def add_shp(self, filename, layer_name=None, random_color_column=None, **kwargs):
def add_shp(
self,
filename: str,
layer_name: Optional[str] = None,
random_color_column: Optional[str] = None,
**kwargs,
) -> None:
"""Adds a shapefile to the map.
Args:
Expand All @@ -347,7 +370,13 @@ def add_shp(self, filename, layer_name=None, random_color_column=None, **kwargs)
"""
self.add_vector(filename, layer_name, random_color_column, **kwargs)

def add_kml(self, filename, layer_name=None, random_color_column=None, **kwargs):
def add_kml(
self,
filename: str,
layer_name: Optional[str] = None,
random_color_column: Optional[str] = None,
**kwargs,
) -> None:
"""Adds a KML file to the map.
Args:
Expand Down

0 comments on commit 123d486

Please sign in to comment.