Skip to content

Commit 3009538

Browse files
authored
Swap out tzwhere for TimezoneFinder. (#230)
* Swap out tzwhere for TimezoneFinder. tzwhere is barely maintained and have not seen new releases in five years. Swap it out for TimezoneFinder. * Lock TimezoneFinder to v6.0.1. Versions newer than 6.0.1 also bumps NumPy dependency causing Python 3.7 to not work. This break Python 3.11 support. * Updated Poetry lock. CI now run local on Python 3.10.
1 parent 2fc6011 commit 3009538

File tree

5 files changed

+937
-279
lines changed

5 files changed

+937
-279
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
name: "CI"
3-
concurrency: # Cancel any existing runs of this workflow for this same PR
3+
concurrency: # Cancel any existing runs of this workflow for this same PR
44
group: "${{ github.workflow }}-${{ github.ref }}"
55
cancel-in-progress: true
6-
on: # yamllint disable
6+
on: # yamllint disable
77
push:
88
branches:
99
- "main"

circuit_maintenance_parser/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from geopy.exc import GeocoderUnavailable, GeocoderTimedOut, GeocoderServiceError # type: ignore
88
from geopy.geocoders import Nominatim # type: ignore
9-
from tzwhere import tzwhere # type: ignore
9+
from timezonefinder import TimezoneFinder # type: ignore
1010
import backoff # type: ignore
1111

1212
from .errors import ParserError
@@ -39,7 +39,7 @@ class Geolocator:
3939
def timezone(cls): # pylint: disable=no-self-argument
4040
"""Load the timezone resolver."""
4141
if cls._timezone is None:
42-
cls._timezone = tzwhere.tzwhere()
42+
cls._timezone = TimezoneFinder()
4343
logger.info("Loaded local timezone resolver.")
4444
return cls._timezone
4545

@@ -110,12 +110,12 @@ def city_timezone(self, city: str) -> str:
110110
if self.timezone is not None:
111111
try:
112112
latitude, longitude = self.get_location(city)
113-
timezone = self.timezone.tzNameAt(latitude, longitude) # pylint: disable=no-member
113+
timezone = self.timezone.timezone_at(lat=latitude, lng=longitude) # pylint: disable=no-member
114114
if not timezone:
115115
# In some cases, given a latitued and longitued, the tzwhere library returns
116116
# an empty timezone, so we try with the coordinates from the API as an alternative
117117
latitude, longitude = self.get_location_from_api(city)
118-
timezone = self.timezone.tzNameAt(latitude, longitude) # pylint: disable=no-member
118+
timezone = self.timezone.timezone_at(lat=latitude, lng=longitude) # pylint: disable=no-member
119119

120120
if timezone:
121121
logger.debug("Matched city %s to timezone %s", city, timezone)

0 commit comments

Comments
 (0)