Skip to content

Commit

Permalink
Add mypy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyyo committed Mar 21, 2023
1 parent 645e07d commit 3345251
Show file tree
Hide file tree
Showing 18 changed files with 577 additions and 298 deletions.
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

0 comments on commit 3345251

Please sign in to comment.