Skip to content

Commit bc00789

Browse files
changed some more type hints to be python3.8 compatible #745
1 parent dc7f57d commit bc00789

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

openeo/extra/job_management/job_splitting.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import abc
22
import math
3-
from typing import List, NamedTuple, Optional, Union
3+
from typing import Dict, List, NamedTuple, Optional, Union
44

55
import pyproj
66
import shapely
@@ -13,7 +13,7 @@ class JobSplittingFailure(Exception):
1313

1414

1515
# TODO: This function is also defined in openeo-python-driver. But maybe we want to avoid a dependency on openeo-python-driver?
16-
def reproject_bounding_box(bbox: dict, from_crs: Optional[str], to_crs: str) -> dict:
16+
def reproject_bounding_box(bbox: Dict, from_crs: Optional[str], to_crs: str) -> Dict:
1717
"""
1818
Reproject given bounding box dictionary
1919
@@ -41,15 +41,15 @@ class BoundingBox(NamedTuple):
4141
crs: str = "EPSG:4326"
4242

4343
@classmethod
44-
def from_dict(cls, d: dict) -> "BoundingBox":
44+
def from_dict(cls, d: Dict) -> "BoundingBox":
4545
return cls(**{k: d[k] for k in cls._fields if k not in cls._field_defaults or k in d})
4646

4747
@classmethod
4848
def from_polygon(cls, polygon: shapely.geometry.Polygon, projection: Optional[str] = None) -> "BoundingBox":
4949
"""Create a bounding box from a shapely Polygon"""
5050
return cls(*polygon.bounds, projection if projection is not None else cls.crs)
5151

52-
def as_dict(self) -> dict:
52+
def as_dict(self) -> Dict:
5353
return self._asdict()
5454

5555
def as_polygon(self) -> shapely.geometry.Polygon:
@@ -61,7 +61,7 @@ class TileGridInterface(metaclass=abc.ABCMeta):
6161
"""Interface for tile grid classes"""
6262

6363
@abc.abstractmethod
64-
def get_tiles(self, geometry: Union[dict, shapely.geometry.Polygon]) -> list[Union[dict, shapely.geometry.Polygon]]:
64+
def get_tiles(self, geometry: Union[Dict, shapely.geometry.Polygon]) -> List[Union[Dict, shapely.geometry.Polygon]]:
6565
"""Calculate tiles to cover given bounding box"""
6666
...
6767

@@ -80,7 +80,7 @@ def from_size_projection(cls, size: float, projection: str) -> "SizeBasedTileGri
8080
"""Create a tile grid from size and projection"""
8181
return cls(projection.lower(), size)
8282

83-
def get_tiles(self, geometry: Union[dict, shapely.geometry.Polygon]) -> list[Union[dict, shapely.geometry.Polygon]]:
83+
def get_tiles(self, geometry: Union[Dict, shapely.geometry.Polygon]) -> List[Union[Dict, shapely.geometry.Polygon]]:
8484
if isinstance(geometry, dict):
8585
bbox = BoundingBox.from_dict(geometry)
8686
bbox_crs = bbox.crs
@@ -123,8 +123,8 @@ def get_tiles(self, geometry: Union[dict, shapely.geometry.Polygon]) -> list[Uni
123123

124124

125125
def split_area(
126-
aoi: Union[dict, shapely.geometry.Polygon], projection="EPSG:326", tile_size: float = 20.0
127-
) -> list[Union[dict, shapely.geometry.Polygon]]:
126+
aoi: Union[Dict, shapely.geometry.Polygon], projection="EPSG:326", tile_size: float = 20.0
127+
) -> List[Union[Dict, shapely.geometry.Polygon]]:
128128
"""
129129
Split area of interest into tiles of given size and projection.
130130
:param aoi: area of interest (bounding box or shapely polygon)

0 commit comments

Comments
 (0)