Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -44,6 +44,7 @@ jobs:

- name: Run tests
run: |
python3 -m nox --session "mypy-${{ matrix.python-version }}"
python3 -m nox --session "tests-${{ matrix.python-version }}"
python3 -m nox -e distribution
test:
Expand Down
23 changes: 19 additions & 4 deletions googlemaps/addressvalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,28 @@
#

"""Performs requests to the Google Maps Address Validation API."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast, List, Optional

import requests

from googlemaps import exceptions
from googlemaps.types import DictStrAny

if TYPE_CHECKING:
from googlemaps.client import Client


_ADDRESSVALIDATION_BASE_URL = "https://addressvalidation.googleapis.com"


def _addressvalidation_extract(response):
def _addressvalidation_extract(response: requests.Response) -> DictStrAny:
"""
Mimics the exception handling logic in ``client._get_body``, but
for addressvalidation which uses a different response format.
"""
body = response.json()
return body
return cast(DictStrAny, body)

# if response.status_code in (200, 404):
# return body
Expand All @@ -44,7 +53,13 @@ def _addressvalidation_extract(response):
# raise exceptions.ApiError(response.status_code, error)


def addressvalidation(client, addressLines, regionCode=None , locality=None, enableUspsCass=None):
def addressvalidation(
client: Client,
addressLines: List[str],
regionCode: Optional[str] = None,
locality: Optional[str] = None,
enableUspsCass: Optional[bool] = None,
) -> DictStrAny:
"""
The Google Maps Address Validation API returns a verification of an address
See https://developers.google.com/maps/documentation/address-validation/overview
Expand All @@ -59,7 +74,7 @@ def addressvalidation(client, addressLines, regionCode=None , locality=None, ena
:type locality: boolean
"""

params = {
params: DictStrAny = {
"address":{
"addressLines": addressLines
}
Expand Down
Loading