Skip to content

Commit

Permalink
Code cleanup and improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
agrenott committed Jan 9, 2024
1 parent 74e39d1 commit 433f802
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 129 deletions.
7 changes: 5 additions & 2 deletions pyhgtmap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from importlib.metadata import version
from typing import List, Tuple

__author__ = "Aurélien Grenotton (agrenott@gmail.com)"
__version__ = version("pyhgtmap")
__license__ = "GPLv2+"

# Can't use __future__ annotations for type aliases: https://github.com/python/cpython/issues/95805
# Some type aliases
Polygon = list[tuple[float, float]]
PolygonsList = list[Polygon]
Polygon = List[Tuple[float, float]]
PolygonsList = List[Polygon]
BoudingBox = Tuple[float, float, float, float]
9 changes: 6 additions & 3 deletions pyhgtmap/hgt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

from typing import Callable, Iterable, Tuple
from typing import TYPE_CHECKING, Callable, Iterable, Tuple

if TYPE_CHECKING:
from pyhgtmap import BoudingBox

# Coordinates transformation function prototype
TransformFunType = Callable[
Expand All @@ -9,7 +12,7 @@
]


def makeBBoxString(bbox: tuple[float, float, float, float]) -> str:
def makeBBoxString(bbox: BoudingBox) -> str:
return f"{{0:s}}lon{bbox[0]:.2f}_{bbox[2]:.2f}lat{bbox[1]:.2f}_{bbox[3]:.2f}"


Expand All @@ -19,7 +22,7 @@ def transformLonLats(
maxLon: float,
maxLat: float,
transform: TransformFunType | None,
) -> tuple[float, float, float, float]:
) -> BoudingBox:
if transform is None:
return minLon, minLat, maxLon, maxLat
else:
Expand Down
File renamed without changes.
Loading

0 comments on commit 433f802

Please sign in to comment.