Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hansthen committed Jan 25, 2024
1 parent 1e79985 commit 4c829f6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions folium/plugins/timeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, TextIO, Union
from typing import Optional, Union

import isodate
import jq
Expand Down Expand Up @@ -211,12 +211,12 @@ class Timeline(JSCSSMixin, MacroElement):

def __init__(
self,
data: Union[TextIO, str, dict],
duration: str = None,
data: Union[dict],
duration: Optional[str] = None,
convert: bool = True,
get_interval: Optional[JsCode] = None,
start: Union[str, int, float] = None,
end: Union[str, int, float] = None,
start: Optional[Union[str, int, float]] = None,
end: Optional[Union[str, int, float]] = None,
add_last_point: bool = True,
auto_play: bool = True,
format_output: Optional[JsCode] = format_output,
Expand Down Expand Up @@ -277,11 +277,13 @@ def _convert_to_feature_collection(obj) -> dict:
return {"type": "FeatureCollection", "features": [obj]}


def _convert_from_times(obj: dict, duration: str, add_last_point: bool) -> dict:
def _convert_from_times(
obj: dict, duration: Optional[str], add_last_point: bool
) -> dict:
"Converts a GeoJson from the TimeDimension format to the Timeline format"
obj = _convert_to_feature_collection(obj)
if duration is not None:
duration = int(isodate.parse_duration(duration).total_seconds() * 1000)
duration = str(int(isodate.parse_duration(duration).total_seconds() * 1000))
else:
# if duration is none, we show until the end of times
duration = (
Expand Down

0 comments on commit 4c829f6

Please sign in to comment.