Skip to content

Commit

Permalink
fix: add types and return consistent type
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Dec 6, 2024
1 parent 440a783 commit 76ca7f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/masquerade/providers/open_sgid.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def __init__(self, table_name):
super().__init__(f"No table found: {table_name}")


def get_boundary_value(x, y, spatial_reference, table_name, field_name):
def get_boundary_value(x: float, y: float, spatial_reference: int, table_name: str, field_name: str) -> str | None:
"""return the value of a given field for a point within a specified boundary table"""
query = f"""
select {field_name} from {table_name}
Expand All @@ -407,16 +407,16 @@ def get_boundary_value(x, y, spatial_reference, table_name, field_name):
return None


def get_zip(x, y, spatial_reference):
def get_zip(x: float, y: float, spatial_reference: int) -> str | None:
"""return the zip code for a given point"""
return get_boundary_value(x, y, spatial_reference, "opensgid.boundaries.zip_code_areas", "zip5")


def get_city(x, y, spatial_reference):
def get_city(x: float, y: float, spatial_reference: int) -> str | None:
"""return the city for a given point"""
return get_boundary_value(x, y, spatial_reference, "opensgid.boundaries.municipal_boundaries", "name")


def get_county(x, y, spatial_reference):
def get_county(x: float, y: float, spatial_reference: int) -> str | None:
"""return the county for a given point"""
return get_boundary_value(x, y, spatial_reference, "opensgid.boundaries.county_boundaries", "name")
2 changes: 1 addition & 1 deletion src/masquerade/providers/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def reverse_geocode(x: float, y: float, spatial_reference: int, input_x: float,
api_result = response.json()["result"]
except Exception:
current_app.warning(f"Error parsing web api reverse geocode result: {response.text}")
return None
return result

street = api_result["address"]["street"]
address_type = api_result["address"]["addressType"]
Expand Down

0 comments on commit 76ca7f0

Please sign in to comment.