Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions geonamescache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)

TDict = TypeVar('TDict', bound=Mapping[str, Any])
TData = TypeVar('TData')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to underscore these (and get_dataset_by_key() as well), but that has an API effect and can get done at some later date.



class GeonamesCache:
Expand Down Expand Up @@ -72,7 +73,7 @@ def get_cities_by_name(self, name: str) -> list[dict[GeoNameIdStr, City]]:
self.cities_by_names[name] = [{gid: city} for gid, city in self.cities_items if city['name'] == name]
return self.cities_by_names[name]

def get_us_counties(self):
def get_us_counties(self) -> list[USCounty]:
return self._load_data(self.us_counties, 'us_counties.json')

def search_cities(
Expand Down Expand Up @@ -105,7 +106,7 @@ def search_cities(
return results

@staticmethod
def _load_data(datadict: dict[Any, Any] | None, datafile: str) -> dict[Any, Any]:
def _load_data(datadict: TData | None, datafile: str) -> TData:
if datadict is None:
with open(os.path.join(os.path.dirname(__file__), 'data', datafile)) as f:
datadict = json.load(f)
Expand Down