From 14a8f0b92b55405a3853682c155c1d9329a9823b Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 11:49:10 -0600 Subject: [PATCH 01/62] chore: run publish in release exec (#401) --- .github/scripts/install.sh | 2 +- .github/workflows/publish.yml | 48 ----------------------------------- .github/workflows/release.yml | 10 ++++++++ .releaserc | 11 ++++++-- 4 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh index 5cd76712..91235742 100755 --- a/.github/scripts/install.sh +++ b/.github/scripts/install.sh @@ -6,7 +6,7 @@ if ! python3 -m pip --version; then curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python3 get-pip.py sudo python3 -m pip install --upgrade setuptools - sudo python3 -m pip install nox + sudo python3 -m pip install nox twine else sudo python3 -m pip install --upgrade setuptools python3 -m pip install nox diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index a0ea83af..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# A workflow that pushes artifacts to Sonatype -name: Publish - -on: - push: - tags: - - '*' - repository_dispatch: - types: [publish] - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Python - uses: "actions/setup-python@v1" - with: - python-version: "3.6" - - - name: Install dependencies - run: ./.github/scripts/install.sh - - - name: Run distribution - run: python3 -m nox -e distribution - - - name: Deploy to PyPi - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bebedf46..d27f41d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,10 +20,18 @@ jobs: release: runs-on: ubuntu-latest steps: + - name: Setup Python + uses: "actions/setup-python@v1" + with: + python-version: "3.6" - name: Checkout uses: actions/checkout@v2 with: token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} + - name: Install dependencies + run: ./.github/scripts/install.sh + - name: Run distribution + run: python3 -m nox -e distribution - name: Semantic Release uses: cycjimmy/semantic-release-action@v2 with: @@ -35,3 +43,5 @@ jobs: "@semantic-release/github env: GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/.releaserc b/.releaserc index 981e4031..7daf2b19 100644 --- a/.releaserc +++ b/.releaserc @@ -11,8 +11,15 @@ plugins: to: "__version__ = \"${nextRelease.version}\"" - files: - "./setup.py" - from: "version=\".*\"" - to: "version=\"${nextRelease.version}\"" + from: 'version=".*"' + to: 'version="${nextRelease.version}"' + - - "@semantic-release/exec" + - prepareCmd: + - rm -rf dist + - python3 setup.py sdist + - python3 -m twine check dist/* + - publishCmd: + - python3 -m twine upload dist/* - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From bd0788f617679663e3dd7dbafe88ddb05421f9f7 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 18:07:46 +0000 Subject: [PATCH 02/62] chore: include exec plugin --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d27f41d4..c4708c48 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,7 @@ jobs: "@semantic-release/commit-analyzer" "@semantic-release/release-notes-generator" "@google/semantic-release-replace-plugin" + "@semantic-release/exec" "@semantic-release/git "@semantic-release/github env: From fc0d02660f56a4a4a3d2edd7656e2a881701ea0c Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 18:19:03 +0000 Subject: [PATCH 03/62] chore: fix exec command --- .releaserc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.releaserc b/.releaserc index 7daf2b19..6d2b9617 100644 --- a/.releaserc +++ b/.releaserc @@ -14,12 +14,8 @@ plugins: from: 'version=".*"' to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - - prepareCmd: - - rm -rf dist - - python3 setup.py sdist - - python3 -m twine check dist/* - - publishCmd: - - python3 -m twine upload dist/* + - prepareCmd: rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/* + - publishCmd: python3 -m twine upload dist/* - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From 5df4f403ed87fa963fb43b405744ca531a2f6881 Mon Sep 17 00:00:00 2001 From: Andrew Gomez Date: Mon, 15 Mar 2021 13:24:58 -0500 Subject: [PATCH 04/62] docs: specify support for place ID parameter in distance_matrix.py (#400) Updated param comments to specify support for place ID via 'place_id:' Per API documentation: "using place IDs is preferred over using addresses or latitude/longitude coordinates" Created test_place_id_param() to test case when origin/destination consist solely of place IDs. Updated test_mixed_params() to include a place ID in the origin. --- googlemaps/distance_matrix.py | 16 +++++++------- tests/test_distance_matrix.py | 39 +++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/googlemaps/distance_matrix.py b/googlemaps/distance_matrix.py index 1d848253..a30cbe09 100755 --- a/googlemaps/distance_matrix.py +++ b/googlemaps/distance_matrix.py @@ -26,17 +26,19 @@ def distance_matrix(client, origins, destinations, transit_routing_preference=None, traffic_model=None, region=None): """ Gets travel distance and time for a matrix of origins and destinations. - :param origins: One or more locations and/or latitude/longitude values, - from which to calculate distance and time. If you pass an address as - a string, the service will geocode the string and convert it to a + :param origins: One or more addresses, Place IDs, and/or latitude/longitude + values, from which to calculate distance and time. Each Place ID string + must be prepended with 'place_id:'. If you pass an address as a string, + the service will geocode the string and convert it to a latitude/longitude coordinate to calculate directions. :type origins: a single location, or a list of locations, where a location is a string, dict, list, or tuple - :param destinations: One or more addresses and/or lat/lng values, to - which to calculate distance and time. If you pass an address as a - string, the service will geocode the string and convert it to a - latitude/longitude coordinate to calculate directions. + :param destinations: One or more addresses, Place IDs, and/or lat/lng values + , to which to calculate distance and time. Each Place ID string must be + prepended with 'place_id:'. If you pass an address as a string, the + service will geocode the string and convert it to a latitude/longitude + coordinate to calculate directions. :type destinations: a single location, or a list of locations, where a location is a string, dict, list, or tuple diff --git a/tests/test_distance_matrix.py b/tests/test_distance_matrix.py index a906f8ce..6946782e 100644 --- a/tests/test_distance_matrix.py +++ b/tests/test_distance_matrix.py @@ -84,7 +84,10 @@ def test_mixed_params(self): content_type="application/json", ) - origins = ["Bobcaygeon ON", [41.43206, -81.38992]] + origins = [ + "Bobcaygeon ON", [41.43206, -81.38992], + "place_id:ChIJ7cv00DwsDogRAMDACa2m4K8" + ] destinations = [ (43.012486, -83.6964149), {"lat": 42.8863855, "lng": -78.8781627}, @@ -95,7 +98,8 @@ def test_mixed_params(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( "https://maps.googleapis.com/maps/api/distancematrix/json?" - "key=%s&origins=Bobcaygeon+ON%%7C41.43206%%2C-81.38992&" + "key=%s&origins=Bobcaygeon+ON%%7C41.43206%%2C-81.38992%%7C" + "place_id%%3AChIJ7cv00DwsDogRAMDACa2m4K8&" "destinations=43.012486%%2C-83.6964149%%7C42.8863855%%2C" "-78.8781627" % self.key, responses.calls[0].request.url, @@ -181,3 +185,34 @@ def test_lang_param(self): "destinations=San+Francisco%%7CVictoria+BC" % self.key, responses.calls[0].request.url, ) + @responses.activate + def test_place_id_param(self): + responses.add( + responses.GET, + "https://maps.googleapis.com/maps/api/distancematrix/json", + body='{"status":"OK","rows":[]}', + status=200, + content_type="application/json", + ) + + origins = [ + 'place_id:ChIJ7cv00DwsDogRAMDACa2m4K8', + 'place_id:ChIJzxcfI6qAa4cR1jaKJ_j0jhE', + ] + destinations = [ + 'place_id:ChIJPZDrEzLsZIgRoNrpodC5P30', + 'place_id:ChIJjQmTaV0E9YgRC2MLmS_e_mY', + ] + + matrix = self.client.distance_matrix(origins, destinations) + + self.assertEqual(1, len(responses.calls)) + self.assertURLEqual( + "https://maps.googleapis.com/maps/api/distancematrix/json?" + "key=%s&" + "origins=place_id%%3AChIJ7cv00DwsDogRAMDACa2m4K8%%7C" + "place_id%%3AChIJzxcfI6qAa4cR1jaKJ_j0jhE&" + "destinations=place_id%%3AChIJPZDrEzLsZIgRoNrpodC5P30%%7C" + "place_id%%3AChIJjQmTaV0E9YgRC2MLmS_e_mY" % self.key, + responses.calls[0].request.url, + ) From 4ad0c4905972e35d58dce6a9091f84db4640bd3f Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 18:31:10 +0000 Subject: [PATCH 05/62] build: fix escape --- .github/workflows/release.yml | 4 ++-- .releaserc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c4708c48..8e149580 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,8 +40,8 @@ jobs: "@semantic-release/release-notes-generator" "@google/semantic-release-replace-plugin" "@semantic-release/exec" - "@semantic-release/git - "@semantic-release/github + "@semantic-release/git" + "@semantic-release/github" env: GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} TWINE_USERNAME: __token__ diff --git a/.releaserc b/.releaserc index 6d2b9617..d34a775c 100644 --- a/.releaserc +++ b/.releaserc @@ -14,8 +14,8 @@ plugins: from: 'version=".*"' to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - - prepareCmd: rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/* - - publishCmd: python3 -m twine upload dist/* + - prepareCmd: "rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/*" + - publishCmd: "python3 -m twine upload dist/*" - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From 6d2ee9642a1849ed64cdce76692f68a753fc286a Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 19:04:38 +0000 Subject: [PATCH 06/62] chore: options is not an array --- .releaserc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.releaserc b/.releaserc index d34a775c..db70f6e2 100644 --- a/.releaserc +++ b/.releaserc @@ -14,8 +14,8 @@ plugins: from: 'version=".*"' to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - - prepareCmd: "rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/*" - - publishCmd: "python3 -m twine upload dist/*" + - prepareCmd: "rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/*" + publishCmd: "python3 -m twine upload dist/*" - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From b963ff945c2343d34fa9d3b3e6acec02f987ca95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vasi=C4=87?= Date: Mon, 15 Mar 2021 20:14:29 +0100 Subject: [PATCH 07/62] fix: Add parameter 'origin' to places autocomplete (#392) --- googlemaps/places.py | 11 +++++++++++ tests/test_places.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/googlemaps/places.py b/googlemaps/places.py index e288dc91..91c14dfe 100644 --- a/googlemaps/places.py +++ b/googlemaps/places.py @@ -501,6 +501,7 @@ def places_autocomplete( input_text, session_token=None, offset=None, + origin=None, location=None, radius=None, language=None, @@ -525,6 +526,12 @@ def places_autocomplete( service will match on 'Goo'. :type offset: int + :param origin: The origin point from which to calculate straight-line distance + to the destination (returned as distance_meters). + If this value is omitted, straight-line distance will + not be returned. + :type origin: string, dict, list, or tuple + :param location: The latitude/longitude value for which you wish to obtain the closest, human-readable address. :type location: string, dict, list, or tuple @@ -558,6 +565,7 @@ def places_autocomplete( input_text, session_token=session_token, offset=offset, + origin=origin, location=location, radius=radius, language=language, @@ -611,6 +619,7 @@ def _autocomplete( input_text, session_token=None, offset=None, + origin=None, location=None, radius=None, language=None, @@ -629,6 +638,8 @@ def _autocomplete( params["sessiontoken"] = session_token if offset: params["offset"] = offset + if origin: + params["origin"] = convert.latlng(origin) if location: params["location"] = convert.latlng(location) if radius: diff --git a/tests/test_places.py b/tests/test_places.py index 5316fe8e..50781773 100644 --- a/tests/test_places.py +++ b/tests/test_places.py @@ -212,6 +212,7 @@ def test_autocomplete(self): "Google", session_token=session_token, offset=3, + origin=self.location, location=self.location, radius=self.radius, language=self.language, @@ -223,6 +224,7 @@ def test_autocomplete(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( "%s?components=country%%3Aau&input=Google&language=en-AU&" + "origin=-33.86746%%2C151.20709&" "location=-33.86746%%2C151.20709&offset=3&radius=100&" "strictbounds=true&types=geocode&key=%s&sessiontoken=%s" % (url, self.key, session_token), From 975071f2d68e4847feae78b9dfe07e9895f2eaef Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 16 Mar 2021 06:15:19 +1100 Subject: [PATCH 08/62] docs: fix simple typo, preffix -> prefix (#389) There is a small typo in googlemaps/directions.py. Should read `prefix` rather than `preffix`. --- googlemaps/directions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/directions.py b/googlemaps/directions.py index b38a4cdf..353145cc 100644 --- a/googlemaps/directions.py +++ b/googlemaps/directions.py @@ -33,7 +33,7 @@ def directions(client, origin, destination, :param destination: The address or latitude/longitude value from which you wish to calculate directions. You can use a place_id as destination - by putting 'place_id:' as a preffix in the passing parameter. + by putting 'place_id:' as a prefix in the passing parameter. :type destination: string, dict, list, or tuple :param mode: Specifies the mode of transport to use when calculating From 923f8f3149d673c163a0b3a65b08b30ef7c9c827 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 15 Mar 2021 19:39:01 +0000 Subject: [PATCH 09/62] chore: update release to match pypa/gh-action-pypi-publish --- .github/scripts/install.sh | 1 + .github/workflows/release.yml | 4 +++- .releaserc | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh index 91235742..a585594c 100755 --- a/.github/scripts/install.sh +++ b/.github/scripts/install.sh @@ -10,4 +10,5 @@ if ! python3 -m pip --version; then else sudo python3 -m pip install --upgrade setuptools python3 -m pip install nox + python3 -m pip install --prefer-binary twine fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e149580..f5704229 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,11 +19,13 @@ on: jobs: release: runs-on: ubuntu-latest + env: + PYTHONDONTWRITEBYTECODE: 1 steps: - name: Setup Python uses: "actions/setup-python@v1" with: - python-version: "3.6" + python-version: "3.9" - name: Checkout uses: actions/checkout@v2 with: diff --git a/.releaserc b/.releaserc index db70f6e2..15fa5beb 100644 --- a/.releaserc +++ b/.releaserc @@ -14,7 +14,7 @@ plugins: from: 'version=".*"' to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - - prepareCmd: "rm -rf dist && python3 setup.py sdist && python3 -m twine check dist/*" + - prepareCmd: "python3 setup.py sdist && python3 -m twine check dist/*" publishCmd: "python3 -m twine upload dist/*" - - "@semantic-release/git" - assets: From 760bbce63e4ea4ad0c300020bad3f53a4159f028 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 15 Mar 2021 19:47:20 +0000 Subject: [PATCH 10/62] chore(release): 4.4.5 [skip ci] ## [4.4.5](https://github.com/googlemaps/google-maps-services-python/compare/v4.4.4...v4.4.5) (2021-03-15) ### Bug Fixes * Add parameter 'origin' to places autocomplete ([#392](https://github.com/googlemaps/google-maps-services-python/issues/392)) ([b963ff9](https://github.com/googlemaps/google-maps-services-python/commit/b963ff945c2343d34fa9d3b3e6acec02f987ca95)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 2bf13650..937db7ee 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.4.4" +__version__ = "4.4.5" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index f7089df2..bda02c1f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.4.4", + version="4.4.5", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From a9460c0138ea95d4eacfe4ed2dcd1528ad7c4b54 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 15:29:09 -0600 Subject: [PATCH 11/62] chore: Upgrade to GitHub-native Dependabot (#405) Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..491deae0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 From 68276459f1d9cb3317c0c6c81b5ef9d6f45cd6b8 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Wed, 14 Jul 2021 09:40:33 -0600 Subject: [PATCH 12/62] fix: allow channel without client_id (#411) --- googlemaps/client.py | 6 ++---- tests/test_client.py | 4 ---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index 980509e2..7b84b7b4 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -130,13 +130,11 @@ def __init__(self, key=None, client_id=None, client_secret=None, raise ValueError("Invalid API key provided.") if channel: - if not client_id: - raise ValueError("The channel argument must be used with a " - "client ID") if not re.match("^[a-zA-Z0-9._-]*$", channel): raise ValueError("The channel argument must be an ASCII " "alphanumeric string. The period (.), underscore (_)" - "and hyphen (-) characters are allowed.") + "and hyphen (-) characters are allowed. If used without " + "client_id, it must be 0-999.") self.session = requests.Session() self.key = key diff --git a/tests/test_client.py b/tests/test_client.py index a18221fa..4f01e397 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -280,10 +280,6 @@ def __call__(self, req): self.assertEqual(2, len(responses.calls)) - def test_channel_without_client_id(self): - with self.assertRaises(ValueError): - client = googlemaps.Client(key="AIzaasdf", channel="mychannel") - def test_invalid_channel(self): # Cf. limitations here: # https://developers.google.com/maps/premium/reports From cca7a307774c35cfae24d0311e8211d3220f3fb4 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 14 Jul 2021 15:41:47 +0000 Subject: [PATCH 13/62] chore(release): 4.4.6 [skip ci] ## [4.4.6](https://github.com/googlemaps/google-maps-services-python/compare/v4.4.5...v4.4.6) (2021-07-14) ### Bug Fixes * allow channel without client_id ([#411](https://github.com/googlemaps/google-maps-services-python/issues/411)) ([6827645](https://github.com/googlemaps/google-maps-services-python/commit/68276459f1d9cb3317c0c6c81b5ef9d6f45cd6b8)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 937db7ee..a0b81a69 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.4.5" +__version__ = "4.4.6" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index bda02c1f..4bdae609 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.4.5", + version="4.4.6", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From a8afb86892ed06857099aecf10ca63c2271ce569 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Wed, 14 Jul 2021 09:50:58 -0600 Subject: [PATCH 14/62] fix: run sdist after tag created --- .releaserc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.releaserc b/.releaserc index 15fa5beb..78e982ac 100644 --- a/.releaserc +++ b/.releaserc @@ -15,7 +15,7 @@ plugins: to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - prepareCmd: "python3 setup.py sdist && python3 -m twine check dist/*" - publishCmd: "python3 -m twine upload dist/*" + publishCmd: "python3 setup.py sdist && python3 -m twine upload dist/*" - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From 8ad82645782a3d7417ca82b1a0cb31ab7930238b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 14 Jul 2021 15:52:17 +0000 Subject: [PATCH 15/62] chore(release): 4.4.7 [skip ci] ## [4.4.7](https://github.com/googlemaps/google-maps-services-python/compare/v4.4.6...v4.4.7) (2021-07-14) ### Bug Fixes * run sdist after tag created ([a8afb86](https://github.com/googlemaps/google-maps-services-python/commit/a8afb86892ed06857099aecf10ca63c2271ce569)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index a0b81a69..6649d28a 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.4.6" +__version__ = "4.4.7" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 4bdae609..99273db0 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.4.6", + version="4.4.7", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 891321c3209e13130b760661d23b2e5cd741e39f Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Wed, 14 Jul 2021 10:55:13 -0600 Subject: [PATCH 16/62] chore: delete unnecessary file --- .deepsource.toml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml deleted file mode 100644 index f772ce8c..00000000 --- a/.deepsource.toml +++ /dev/null @@ -1,10 +0,0 @@ -version = 1 - -test_patterns = ["tests/**"] - -[[analyzers]] -name = "python" -enabled = true - - [analyzers.meta] - runtime_version = "3.x.x" From a93b3c0fe1ec4680fbb34fc29ac8714b9a8c7da4 Mon Sep 17 00:00:00 2001 From: northtree Date: Thu, 29 Jul 2021 23:42:53 +1000 Subject: [PATCH 17/62] feat: allow passings requests session (#414) --- googlemaps/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index 7b84b7b4..1334571d 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -54,6 +54,7 @@ def __init__(self, key=None, client_id=None, client_secret=None, retry_timeout=60, requests_kwargs=None, queries_per_second=50, channel=None, retry_over_query_limit=True, experience_id=None, + requests_session=None, base_url=_DEFAULT_BASE_URL): """ :param key: Maps API key. Required, unless "client_id" and @@ -116,6 +117,9 @@ def __init__(self, key=None, client_id=None, client_secret=None, implemented. See the official requests docs for more info: http://docs.python-requests.org/en/latest/api/#main-interface :type requests_kwargs: dict + + :param requests_session: Reused persistent session for flexibility. + :type requests_session: requests.Session :param base_url: The base URL for all requests. Defaults to the Maps API server. Should not have a trailing slash. @@ -136,7 +140,7 @@ def __init__(self, key=None, client_id=None, client_secret=None, "and hyphen (-) characters are allowed. If used without " "client_id, it must be 0-999.") - self.session = requests.Session() + self.session = requests_session or requests.Session() self.key = key if timeout and (connect_timeout or read_timeout): From 0717028106b0b9ba7f2fc607f7b2cbabdf25dcd6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 29 Jul 2021 13:44:22 +0000 Subject: [PATCH 18/62] chore(release): 4.5.0 [skip ci] # [4.5.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.4.7...v4.5.0) (2021-07-29) ### Features * allow passings requests session ([#414](https://github.com/googlemaps/google-maps-services-python/issues/414)) ([a93b3c0](https://github.com/googlemaps/google-maps-services-python/commit/a93b3c0fe1ec4680fbb34fc29ac8714b9a8c7da4)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 6649d28a..803bf5a9 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.4.7" +__version__ = "4.5.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 99273db0..c2a605ba 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.4.7", + version="4.5.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From c7c32368811ada02a96b05480cbdb595639c44fa Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 29 Jul 2021 08:16:33 -0600 Subject: [PATCH 19/62] fix: only run publishCmd --- .releaserc | 1 - 1 file changed, 1 deletion(-) diff --git a/.releaserc b/.releaserc index 78e982ac..469c01f0 100644 --- a/.releaserc +++ b/.releaserc @@ -14,7 +14,6 @@ plugins: from: 'version=".*"' to: 'version="${nextRelease.version}"' - - "@semantic-release/exec" - - prepareCmd: "python3 setup.py sdist && python3 -m twine check dist/*" publishCmd: "python3 setup.py sdist && python3 -m twine upload dist/*" - - "@semantic-release/git" - assets: From 3502f8afdee1ba14b9acba7d8693225ca05bb80f Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 29 Jul 2021 08:22:46 -0600 Subject: [PATCH 20/62] chore: fix formatting --- .releaserc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.releaserc b/.releaserc index 469c01f0..5f53e6f5 100644 --- a/.releaserc +++ b/.releaserc @@ -13,8 +13,7 @@ plugins: - "./setup.py" from: 'version=".*"' to: 'version="${nextRelease.version}"' - - - "@semantic-release/exec" - publishCmd: "python3 setup.py sdist && python3 -m twine upload dist/*" + - [ "@semantic-release/exec", { publishCmd: "python3 setup.py sdist && python3 -m twine upload dist/*" }] - - "@semantic-release/git" - assets: - "./googlemaps/__init__.py" From 5045dce3eaf793ff20ab5b33c78402b1c501f329 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 29 Jul 2021 14:24:08 +0000 Subject: [PATCH 21/62] chore(release): 4.5.1 [skip ci] ## [4.5.1](https://github.com/googlemaps/google-maps-services-python/compare/v4.5.0...v4.5.1) (2021-07-29) ### Bug Fixes * only run publishCmd ([c7c3236](https://github.com/googlemaps/google-maps-services-python/commit/c7c32368811ada02a96b05480cbdb595639c44fa)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 803bf5a9..593f4ba8 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.5.0" +__version__ = "4.5.1" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index c2a605ba..369cb0b5 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.5.0", + version="4.5.1", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From dc8e116992666cac83bea7d41aac864eeea1d882 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 29 Jul 2021 08:34:30 -0600 Subject: [PATCH 22/62] fix: cleanup old dist --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5704229..869f8d65 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,8 @@ jobs: run: ./.github/scripts/install.sh - name: Run distribution run: python3 -m nox -e distribution + - name: Cleanup old dist + run: rm -rf googlemaps-* - name: Semantic Release uses: cycjimmy/semantic-release-action@v2 with: From 5420d7d1f7bc1945e50e62d6c8a910657249a34d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 29 Jul 2021 14:35:53 +0000 Subject: [PATCH 23/62] chore(release): 4.5.2 [skip ci] ## [4.5.2](https://github.com/googlemaps/google-maps-services-python/compare/v4.5.1...v4.5.2) (2021-07-29) ### Bug Fixes * cleanup old dist ([dc8e116](https://github.com/googlemaps/google-maps-services-python/commit/dc8e116992666cac83bea7d41aac864eeea1d882)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 593f4ba8..b272c645 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.5.1" +__version__ = "4.5.2" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 369cb0b5..bff54133 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.5.1", + version="4.5.2", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 964cecd5ce2df29ac5cd91e62560cd0a69c7125d Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 29 Jul 2021 08:38:49 -0600 Subject: [PATCH 24/62] fix: cleanup dist --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 869f8d65..ce78e642 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: - name: Run distribution run: python3 -m nox -e distribution - name: Cleanup old dist - run: rm -rf googlemaps-* + run: rm -rf googlemaps-* dist/ - name: Semantic Release uses: cycjimmy/semantic-release-action@v2 with: From 00a87a0f623c00286f20e3f4c576a62a73284e5c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 29 Jul 2021 14:39:57 +0000 Subject: [PATCH 25/62] chore(release): 4.5.3 [skip ci] ## [4.5.3](https://github.com/googlemaps/google-maps-services-python/compare/v4.5.2...v4.5.3) (2021-07-29) ### Bug Fixes * cleanup dist ([964cecd](https://github.com/googlemaps/google-maps-services-python/commit/964cecd5ce2df29ac5cd91e62560cd0a69c7125d)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index b272c645..63665644 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.5.2" +__version__ = "4.5.3" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index bff54133..be29f9b1 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.5.2", + version="4.5.3", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 25e26092cb19e998764cae37474dd4c35ff42473 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Fri, 1 Oct 2021 11:15:52 -0600 Subject: [PATCH 26/62] chore: Created local 'SECURITY.md' from remote 'SECURITY.md' (#418) --- SECURITY.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..6d19135d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,10 @@ +# Report a security issue + +To report a security issue, please use https://g.co/vulnz. We use +https://g.co/vulnz for our intake, and do coordination and disclosure here on +GitHub (including using GitHub Security Advisory). The Google Security Team will +respond within 5 working days of your report on g.co/vulnz. + +To contact us about other bugs, please open an issue on GitHub. + +> **Note**: This file is synchronized from the https://github.com/googlemaps/.github repository. From db1292f267897d1bd5db34655f1745e61d1a96c6 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Wed, 2 Feb 2022 13:52:31 -0700 Subject: [PATCH 27/62] chore: update test matrix python versions (#428) --- .github/workflows/test.yml | 2 +- noxfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58839686..f8123e23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.7", "3.8"] + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/noxfile.py b/noxfile.py index 06eefe58..d3357fe4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,6 @@ import nox -SUPPORTED_PY_VERSIONS = ["3.5", "3.6", "3.7", "3.8"] +SUPPORTED_PY_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] def _install_dev_packages(session): From 1364711c1557b44e72d1ea60d53a7f134f892de6 Mon Sep 17 00:00:00 2001 From: Andy Klimczak Date: Wed, 2 Feb 2022 16:15:53 -0500 Subject: [PATCH 28/62] feat: Geocode by place id (#427) Geocode endpoint accepts a `place_id` param as an alternative to geocode Google docs: https://developers.google.com/maps/documentation/geocoding/requests-places-geocoding --- googlemaps/geocoding.py | 9 ++++++++- tests/test_geocoding.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/googlemaps/geocoding.py b/googlemaps/geocoding.py index b665d776..e409a49e 100644 --- a/googlemaps/geocoding.py +++ b/googlemaps/geocoding.py @@ -19,7 +19,7 @@ from googlemaps import convert -def geocode(client, address=None, components=None, bounds=None, region=None, +def geocode(client, address=None, place_id=None, components=None, bounds=None, region=None, language=None): """ Geocoding is the process of converting addresses @@ -30,6 +30,10 @@ def geocode(client, address=None, components=None, bounds=None, region=None, :param address: The address to geocode. :type address: string + :param place_id: A textual identifier that uniquely identifies a place, + returned from a Places search. + :type place_id: string + :param components: A component filter for which you wish to obtain a geocode, for example: ``{'administrative_area': 'TX','country': 'US'}`` :type components: dict @@ -53,6 +57,9 @@ def geocode(client, address=None, components=None, bounds=None, region=None, if address: params["address"] = address + if place_id: + params["place_id"] = place_id + if components: params["components"] = convert.components(components) diff --git a/tests/test_geocoding.py b/tests/test_geocoding.py index dfd9376d..813241f6 100644 --- a/tests/test_geocoding.py +++ b/tests/test_geocoding.py @@ -201,6 +201,25 @@ def test_geocode_with_just_components(self): responses.calls[0].request.url, ) + @responses.activate + def test_geocode_place_id(self): + responses.add( + responses.GET, + "https://maps.googleapis.com/maps/api/geocode/json", + body='{"status":"OK","results":[]}', + status=200, + content_type="application/json", + ) + + results = self.client.geocode(place_id="ChIJeRpOeF67j4AR9ydy_PIzPuM") + + self.assertEqual(1, len(responses.calls)) + self.assertURLEqual( + "https://maps.googleapis.com/maps/api/geocode/json?" + "key=%s&place_id=ChIJeRpOeF67j4AR9ydy_PIzPuM" % self.key, + responses.calls[0].request.url, + ) + @responses.activate def test_simple_reverse_geocode(self): responses.add( From 4dd8db6b53049869cf98f2fed3ba8e56676d1709 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 2 Feb 2022 21:17:04 +0000 Subject: [PATCH 29/62] chore(release): 4.6.0 [skip ci] # [4.6.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.5.3...v4.6.0) (2022-02-02) ### Features * Geocode by place id ([#427](https://github.com/googlemaps/google-maps-services-python/issues/427)) ([1364711](https://github.com/googlemaps/google-maps-services-python/commit/1364711c1557b44e72d1ea60d53a7f134f892de6)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 63665644..ffde203b 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.5.3" +__version__ = "4.6.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index be29f9b1..8826822d 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="googlemaps", - version="4.5.3", + version="4.6.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 2723079fce5a677ae068568018900c391b1a1f69 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Mon, 9 May 2022 14:54:46 -0600 Subject: [PATCH 30/62] chore: Synced file(s) with googlemaps/.github (#432) * chore: Created local '.github/CODEOWNERS' from remote '.github/CODEOWNERS' * chore: Created local '.github/sync-repo-settings.yaml' from remote '.github/sync-repo-settings.yaml' --- .github/CODEOWNERS | 17 +++++++++++++++ .github/sync-repo-settings.yaml | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/sync-repo-settings.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..e95e611e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +.github/ @googlemaps/admin diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml new file mode 100644 index 00000000..84693ce8 --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,38 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings + +rebaseMergeAllowed: true +squashMergeAllowed: true +mergeCommitAllowed: false +deleteBranchOnMerge: true +branchProtectionRules: +- pattern: main + isAdminEnforced: false + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - 'cla/google' + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true +- pattern: master + isAdminEnforced: false + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - 'cla/google' + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true +permissionRules: + - team: admin + permission: admin From 628ab311f8416a2b49a4acbccb8d27747bf0a4a5 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Mon, 9 May 2022 15:36:13 -0600 Subject: [PATCH 31/62] chore: Synced local '.github/sync-repo-settings.yaml' with remote '.github/sync-repo-settings.yaml' (#433) --- .github/sync-repo-settings.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 84693ce8..98d0b463 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -24,6 +24,7 @@ branchProtectionRules: requiresStrictStatusChecks: false requiredStatusCheckContexts: - 'cla/google' + - 'test' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true - pattern: master @@ -31,6 +32,7 @@ branchProtectionRules: requiresStrictStatusChecks: false requiredStatusCheckContexts: - 'cla/google' + - 'test' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true permissionRules: From e710ba7b5aeb9156b5112dbd55bd71903128f8c4 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 12:15:23 -0600 Subject: [PATCH 32/62] build: update required checks (#435) --- .github/sync-repo-settings.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 98d0b463..746f8e52 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -25,6 +25,8 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' + - 'snippet-bot-check' + - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true - pattern: master @@ -33,6 +35,8 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' + - 'snippet-bot-check' + - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true permissionRules: From c67d453305fb103aa6ccc3639cf1733854ea480b Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 12:47:51 -0600 Subject: [PATCH 33/62] chore: fix typo in check name (#436) --- .github/sync-repo-settings.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 746f8e52..a7b2d39c 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -25,7 +25,7 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' - - 'snippet-bot-check' + - 'snippet-bot check' - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true @@ -35,7 +35,7 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' - - 'snippet-bot-check' + - 'snippet-bot check' - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true From 1d995b4420ab369d8c23fcdef8b55e284f80dde0 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 14:06:01 -0600 Subject: [PATCH 34/62] build: update workflow and standardize check name --- .github/workflows/test.yml | 8 +++++++- README.md | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8123e23..ddcc2e6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ on: branches: ['*'] jobs: - test: + matrix: name: "Run tests on Python ${{ matrix.python-version }}" runs-on: ubuntu-latest strategy: @@ -46,3 +46,9 @@ jobs: run: | python3 -m nox --session "tests-${{ matrix.python-version }}" python3 -m nox -e distribution + test: + name: Wait for matrix to finish + needs: [matrix] + runs-on: ubuntu-latest + steps: + - run: echo "Test matrix finished" diff --git a/README.md b/README.md index 31840082..21564486 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Python Client for Google Maps Services ==================================== -[![Build Status](https://travis-ci.org/googlemaps/google-maps-services-python.svg?branch=master)](https://travis-ci.org/googlemaps/google-maps-services-python) +![Test](https://github.com/googlemaps/google-maps-services-js/workflows/test/badge.svg) +![Release](https://github.com/googlemaps/google-maps-services-js/workflows/release/badge.svg) [![codecov](https://codecov.io/gh/googlemaps/google-maps-services-python/branch/master/graph/badge.svg)](https://codecov.io/gh/googlemaps/google-maps-services-python) [![PyPI version](https://badge.fury.io/py/googlemaps.svg)](https://badge.fury.io/py/googlemaps) ![PyPI - Downloads](https://img.shields.io/pypi/dd/googlemaps) From f59f66b81326f8f2b9aeadd41df8bba4ac58ff9b Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 14:34:42 -0600 Subject: [PATCH 35/62] docs: fix badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21564486..54c024b3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Python Client for Google Maps Services ==================================== -![Test](https://github.com/googlemaps/google-maps-services-js/workflows/test/badge.svg) -![Release](https://github.com/googlemaps/google-maps-services-js/workflows/release/badge.svg) +![Test](https://github.com/googlemaps/google-maps-services-js/workflows/Test/badge.svg) +![Release](https://github.com/googlemaps/google-maps-services-js/workflows/Release/badge.svg) [![codecov](https://codecov.io/gh/googlemaps/google-maps-services-python/branch/master/graph/badge.svg)](https://codecov.io/gh/googlemaps/google-maps-services-python) [![PyPI version](https://badge.fury.io/py/googlemaps.svg)](https://badge.fury.io/py/googlemaps) ![PyPI - Downloads](https://img.shields.io/pypi/dd/googlemaps) From dfa5e7f2e5f5a0371f607b07538b6c084d8c5b42 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Tue, 10 May 2022 15:31:35 -0600 Subject: [PATCH 36/62] chore: Created local '.github/workflows/dependabot.yml' from remote '.github/workflows/dependabot.yml' (#434) --- .github/workflows/dependabot.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 00000000..597e7636 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,36 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Dependabot +on: pull_request + +permissions: + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} + steps: + - name: approve + run: gh pr review --comment -b "Automatically approved since dependabot is [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `automatic`." + if: ${{ github.event.label.name == 'automatic' }} + - name: approve-instructions + run: echo "configure dependabot with label 'automatic' to have it automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" + if: ${{ github.event.label.name != 'automatic' }} + - name: merge + run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 381563b0ea97d28beb1a0a54299549536fe6ce9c Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Wed, 11 May 2022 15:35:06 -0600 Subject: [PATCH 37/62] chore: Synced local '.github/workflows/dependabot.yml' with remote '.github/workflows/dependabot.yml' (#437) --- .github/workflows/dependabot.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 597e7636..12013710 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,10 +27,10 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved since dependabot is [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `automatic`." - if: ${{ github.event.label.name == 'automatic' }} + run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." + if: ${{ github.event.label.name != 'do not merge' }} - name: approve-instructions - run: echo "configure dependabot with label 'automatic' to have it automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" - if: ${{ github.event.label.name != 'automatic' }} + run: echo "Configure dependabot with label 'do not merge' to prevent it from being automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" + if: ${{ github.event.label.name == 'do not merge' }} - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 8d334a87946442e6d786f9eb0a80a5840eb3cd72 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:49:55 -0600 Subject: [PATCH 38/62] chore: simplify dependabot workflow --- .github/workflows/dependabot.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 12013710..c4c66544 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -28,9 +28,5 @@ jobs: steps: - name: approve run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." - if: ${{ github.event.label.name != 'do not merge' }} - - name: approve-instructions - run: echo "Configure dependabot with label 'do not merge' to prevent it from being automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" - if: ${{ github.event.label.name == 'do not merge' }} - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From fd2933fc8c23e9caa3bb4a5bc74ae0692babde05 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:52:52 -0600 Subject: [PATCH 39/62] chore: update pull request approval comment --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index c4c66544..b9853abf 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." + run: gh pr review --comment -b "Automatically approved dependabot pull request." - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 407e81be1ded5026752c1412f0c8330ca0caa6bd Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:59:57 -0600 Subject: [PATCH 40/62] chore: fix approval by providing url to pr --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index b9853abf..aacd8097 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved dependabot pull request." + run: gh pr review --comment -b "Automatically approved dependabot pull request." "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 7548bb2487d17e93149c40015c9e8b76576180e3 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 10:09:50 -0600 Subject: [PATCH 41/62] chore: add --approve --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index aacd8097..904a1990 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved dependabot pull request." "$PR_URL" + run: gh pr review --approve --comment -b "Automatically approved dependabot pull request." "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 62e1a306059296b7fb9034b709253e2ed6c6ca9c Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 10:21:04 -0600 Subject: [PATCH 42/62] chore: only approve --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 904a1990..6b46ebbb 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --approve --comment -b "Automatically approved dependabot pull request." "$PR_URL" + run: gh pr review --approve "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 8f7209439db457c38da2ea1b6e9115cb727ee39d Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 19 May 2022 13:24:17 -0600 Subject: [PATCH 43/62] build: change dependabot interval to weekly (#439) --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 491deae0..55a9ccdd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,5 +3,5 @@ updates: - package-ecosystem: pip directory: "/" schedule: - interval: daily + interval: "weekly" open-pull-requests-limit: 10 From 3bcb05f56ec0745d9ecaac677c31963cac8ece18 Mon Sep 17 00:00:00 2001 From: anglarett Date: Wed, 9 Nov 2022 17:19:51 +0100 Subject: [PATCH 44/62] feat: Adds support for Address Validation API (#448) --- .github/dependabot.yml | 14 + .github/scripts/distribution.sh | 14 + .github/scripts/install.sh | 14 + .github/stale.yml | 14 + .gitignore | 2 + README.md | 7 + coverage.xml | 849 ++++++++++++++++++++++++++++++++ docs/conf.py | 14 + googlemaps/addressvalidation.py | 80 +++ googlemaps/client.py | 36 +- noxfile.py | 14 + setup.py | 14 + tests/test_addressvalidation.py | 48 ++ text.py | 19 + 14 files changed, 1133 insertions(+), 6 deletions(-) create mode 100644 coverage.xml create mode 100644 googlemaps/addressvalidation.py create mode 100644 tests/test_addressvalidation.py create mode 100644 text.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 55a9ccdd..36f9436b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + version: 2 updates: - package-ecosystem: pip diff --git a/.github/scripts/distribution.sh b/.github/scripts/distribution.sh index f7c08690..e779cd1d 100755 --- a/.github/scripts/distribution.sh +++ b/.github/scripts/distribution.sh @@ -1,4 +1,18 @@ #!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + rm -rf dist diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh index a585594c..39e7f9f0 100755 --- a/.github/scripts/install.sh +++ b/.github/scripts/install.sh @@ -1,4 +1,18 @@ #!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -exo pipefail diff --git a/.github/stale.yml b/.github/stale.yml index 8ed0e080..1d39e65d 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Configuration for probot-stale - https://github.com/probot/stale # Number of days of inactivity before an Issue or Pull Request becomes stale diff --git a/.gitignore b/.gitignore index c4477ba5..74d89080 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ googlemaps.egg-info *.egg .vscode/ .idea/ +index.py +test.py diff --git a/README.md b/README.md index 54c024b3..cb5f7821 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ APIs: - Roads API - Places API - Maps Static API + - Address Validation API Keep in mind that the same [terms and conditions](https://developers.google.com/maps/terms) apply to usage of the APIs when they're accessed through this library. @@ -85,6 +86,12 @@ directions_result = gmaps.directions("Sydney Town Hall", "Parramatta, NSW", mode="transit", departure_time=now) + +# Validate an address with address validation +addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'], + regionCode='US', + locality='Mountain View', + enableUspsCass=True) ``` For more usage examples, check out [the tests](https://github.com/googlemaps/google-maps-services-python/tree/master/tests). diff --git a/coverage.xml b/coverage.xml new file mode 100644 index 00000000..1c38ca3d --- /dev/null +++ b/coverage.xml @@ -0,0 +1,849 @@ + + + + + + /Users/anglarett/Public/Drop Box/dev-se-git/google-maps-services-python + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/conf.py b/docs/conf.py index 19cdfef5..0d8314fb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # -*- coding: utf-8 -*- # # Maps API documentation build configuration file, created by diff --git a/googlemaps/addressvalidation.py b/googlemaps/addressvalidation.py new file mode 100644 index 00000000..45b74655 --- /dev/null +++ b/googlemaps/addressvalidation.py @@ -0,0 +1,80 @@ +# +# Copyright 2014 Google Inc. All rights reserved. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +"""Performs requests to the Google Maps Address Validation API.""" +from googlemaps import exceptions + + +_ADDRESSVALIDATION_BASE_URL = "https://addressvalidation.googleapis.com" + + +def _addressvalidation_extract(response): + """ + Mimics the exception handling logic in ``client._get_body``, but + for addressvalidation which uses a different response format. + """ + body = response.json() + return body + + # if response.status_code in (200, 404): + # return body + + # try: + # error = body["error"]["errors"][0]["reason"] + # except KeyError: + # error = None + + # if response.status_code == 403: + # raise exceptions._OverQueryLimit(response.status_code, error) + # else: + # raise exceptions.ApiError(response.status_code, error) + + +def addressvalidation(client, addressLines, regionCode=None , locality=None, enableUspsCass=None): + """ + The Google Maps Address Validation API returns a verification of an address + See https://developers.google.com/maps/documentation/address-validation/overview + request must include parameters below. + :param addressLines: The address to validate + :type addressLines: array + :param regionCode: (optional) The country code + :type regionCode: string + :param locality: (optional) Restrict to a locality, ie:Mountain View + :type locality: string + :param enableUspsCass For the "US" and "PR" regions only, you can optionally enable the Coding Accuracy Support System (CASS) from the United States Postal Service (USPS) + :type locality: boolean + """ + + params = { + "address":{ + "addressLines": addressLines + } + } + + if regionCode is not None: + params["address"]["regionCode"] = regionCode + + if locality is not None: + params["address"]["locality"] = locality + + if enableUspsCass is not False or enableUspsCass is not None: + params["enableUspsCass"] = enableUspsCass + + return client._request("/v1:validateAddress", {}, # No GET params + base_url=_ADDRESSVALIDATION_BASE_URL, + extract_body=_addressvalidation_extract, + post_json=params) \ No newline at end of file diff --git a/googlemaps/client.py b/googlemaps/client.py index 1334571d..54838fa0 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -31,6 +31,8 @@ import requests import random import time +import math +import sys import googlemaps @@ -52,7 +54,7 @@ class Client: def __init__(self, key=None, client_id=None, client_secret=None, timeout=None, connect_timeout=None, read_timeout=None, retry_timeout=60, requests_kwargs=None, - queries_per_second=50, channel=None, + queries_per_second=60, queries_per_minute=6000,channel=None, retry_over_query_limit=True, experience_id=None, requests_session=None, base_url=_DEFAULT_BASE_URL): @@ -93,11 +95,16 @@ def __init__(self, key=None, client_id=None, client_secret=None, seconds. :type retry_timeout: int - :param queries_per_second: Number of queries per second permitted. + :param queries_per_second: Number of queries per second permitted. Unset queries_per_minute to None. If set smaller number will be used. If the rate limit is reached, the client will sleep for the appropriate amount of time before it runs the current query. :type queries_per_second: int + :param queries_per_minute: Number of queries per minute permitted. Unset queries_per_second to None. If set smaller number will be used. + If the rate limit is reached, the client will sleep for the + appropriate amount of time before it runs the current query. + :type queries_per_minute: int + :param retry_over_query_limit: If True, requests that result in a response indicating the query rate limit was exceeded will be retried. Defaults to True. @@ -169,10 +176,26 @@ def __init__(self, key=None, client_id=None, client_secret=None, "timeout": self.timeout, "verify": True, # NOTE(cbro): verify SSL certs. }) - + + self.queries_quota : int self.queries_per_second = queries_per_second + self.queries_per_minute = queries_per_minute + try: + if (type(self.queries_per_second) == int and type(self.queries_per_minute) == int ): + self.queries_quota = math.floor(min(self.queries_per_second, self.queries_per_minute/60)) + elif (self.queries_per_second and type(self.queries_per_second) == int ): + self.queries_quota = math.floor(self.queries_per_second) + elif (self.queries_per_minute and type(self.queries_per_minute) == int ): + self.queries_quota = math.floor(self.queries_per_minute/60) + else: + sys.exit("MISSING VALID NUMBER for queries_per_second or queries_per_minute") + print("\n","API queries_quota:", self.queries_quota,"\n") + + except NameError: + sys.exit("MISSING VALUE for queries_per_second or queries_per_minute") + self.retry_over_query_limit = retry_over_query_limit - self.sent_times = collections.deque("", queries_per_second) + self.sent_times = collections.deque("", self.queries_quota) self.set_experience_id(experience_id) self.base_url = base_url @@ -303,7 +326,7 @@ def _request(self, url, params, first_request_time=None, retry_counter=0, # Check if the time of the nth previous query (where n is # queries_per_second) is under a second ago - if so, sleep for # the difference. - if self.sent_times and len(self.sent_times) == self.queries_per_second: + if self.sent_times and len(self.sent_times) == self.queries_quota: elapsed_since_earliest = time.time() - self.sent_times[0] if elapsed_since_earliest < 1: time.sleep(1 - elapsed_since_earliest) @@ -402,7 +425,7 @@ def _generate_auth_url(self, path, params, accepts_clientid): from googlemaps.places import places_autocomplete from googlemaps.places import places_autocomplete_query from googlemaps.maps import static_map - +from googlemaps.addressvalidation import addressvalidation def make_api_method(func): """ @@ -446,6 +469,7 @@ def wrapper(*args, **kwargs): Client.places_autocomplete = make_api_method(places_autocomplete) Client.places_autocomplete_query = make_api_method(places_autocomplete_query) Client.static_map = make_api_method(static_map) +Client.addressvalidation = make_api_method(addressvalidation) def sign_hmac(secret, payload): diff --git a/noxfile.py b/noxfile.py index d3357fe4..2bc3b2a1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import nox SUPPORTED_PY_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] diff --git a/setup.py b/setup.py index 8826822d..b2536fc3 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from setuptools import setup diff --git a/tests/test_addressvalidation.py b/tests/test_addressvalidation.py new file mode 100644 index 00000000..69ad8b70 --- /dev/null +++ b/tests/test_addressvalidation.py @@ -0,0 +1,48 @@ +# This Python file uses the following encoding: utf-8 +# +# Copyright 2017 Google Inc. All rights reserved. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +"""Tests for the addressvalidation module.""" + +import responses + +import googlemaps +from . import TestCase + + +class AddressValidationTest(TestCase): + def setUp(self): + self.key = "AIzaasdf" + self.client = googlemaps.Client(self.key) + + @responses.activate + def test_simple_addressvalidation(self): + responses.add( + responses.POST, + "https://addressvalidation.googleapis.com/v1:validateAddress", + body='{"address": {"regionCode": "US","locality": "Mountain View","addressLines": "1600 Amphitheatre Pkwy"},"enableUspsCass":true}', + status=200, + content_type="application/json", + ) + + results = self.client.addressvalidation('1600 Amphitheatre Pk', regionCode='US', locality='Mountain View', enableUspsCass=True) + + self.assertEqual(1, len(responses.calls)) + self.assertURLEqual( + "https://addressvalidation.googleapis.com/v1:validateAddress?" "key=%s" % self.key, + responses.calls[0].request.url, + ) \ No newline at end of file diff --git a/text.py b/text.py new file mode 100644 index 00000000..13734488 --- /dev/null +++ b/text.py @@ -0,0 +1,19 @@ +import math + +queries_quota : int +queries_per_second = 60 # None or 60 +queries_per_minute = None # None or 6000 + +try: + if (type(queries_per_second) == int and type(queries_per_minute) == int ): + queries_quota = math.floor(min(queries_per_second, queries_per_minute/60)) + elif (queries_per_second): + queries_quota = math.floor(queries_per_second) + elif (queries_per_minute): + queries_quota = math.floor(queries_per_minute/60) + else: + print("MISSING VALID NUMBER for queries_per_second or queries_per_minute") + print(queries_quota) + +except NameError: + print("MISSING VALUE for queries_per_second or queries_per_minute") \ No newline at end of file From 6d7a993d49c090c3e06fd1e3bf3019d184279b47 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 9 Nov 2022 16:20:57 +0000 Subject: [PATCH 45/62] chore(release): 4.7.0 [skip ci] # [4.7.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.6.0...v4.7.0) (2022-11-09) ### Features * Adds support for Address Validation API ([#448](https://github.com/googlemaps/google-maps-services-python/issues/448)) ([3bcb05f](https://github.com/googlemaps/google-maps-services-python/commit/3bcb05f56ec0745d9ecaac677c31963cac8ece18)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index ffde203b..4a3b3b91 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.6.0" +__version__ = "4.7.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index b2536fc3..51ccabf8 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.6.0", + version="4.7.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 83ad82772fcfba2ebe798ae544d7f01df1f6ded7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Lilleb=C3=B8=20Gundersen?= Date: Mon, 21 Nov 2022 22:59:47 +0100 Subject: [PATCH 46/62] fix: Convert print statement to info log (#455) --- googlemaps/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index 54838fa0..6684ed1e 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -22,6 +22,7 @@ import base64 import collections +import logging from datetime import datetime from datetime import timedelta import functools @@ -41,6 +42,8 @@ except ImportError: # Python 2 from urllib import urlencode +logger = logging.getLogger(__name__) + _X_GOOG_MAPS_EXPERIENCE_ID = "X-Goog-Maps-Experience-ID" _USER_AGENT = "GoogleGeoApiClientPython/%s" % googlemaps.__version__ _DEFAULT_BASE_URL = "https://maps.googleapis.com" @@ -189,7 +192,7 @@ def __init__(self, key=None, client_id=None, client_secret=None, self.queries_quota = math.floor(self.queries_per_minute/60) else: sys.exit("MISSING VALID NUMBER for queries_per_second or queries_per_minute") - print("\n","API queries_quota:", self.queries_quota,"\n") + logger.info("API queries_quota:", self.queries_quota) except NameError: sys.exit("MISSING VALUE for queries_per_second or queries_per_minute") From 8fde9501b4df675a1ae9f763c29344b407aacf6f Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 21 Nov 2022 22:00:51 +0000 Subject: [PATCH 47/62] chore(release): 4.7.1 [skip ci] ## [4.7.1](https://github.com/googlemaps/google-maps-services-python/compare/v4.7.0...v4.7.1) (2022-11-21) ### Bug Fixes * Convert print statement to info log ([#455](https://github.com/googlemaps/google-maps-services-python/issues/455)) ([83ad827](https://github.com/googlemaps/google-maps-services-python/commit/83ad82772fcfba2ebe798ae544d7f01df1f6ded7)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 4a3b3b91..226be765 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.7.0" +__version__ = "4.7.1" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 51ccabf8..053cd4d8 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.7.0", + version="4.7.1", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 5b952d73f8374baac876b4d845fd46cebec6ed7e Mon Sep 17 00:00:00 2001 From: anglarett Date: Tue, 22 Nov 2022 00:09:25 +0100 Subject: [PATCH 48/62] fix: fixes broken support for python 3.5 (#453) * fix tests * updates after review --- .github/workflows/test.yml | 4 ++-- .gitignore | 1 - googlemaps/addressvalidation.py | 5 +++-- googlemaps/client.py | 1 - tests/test_addressvalidation.py | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddcc2e6c..286ff75a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,10 +32,10 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Python - uses: "actions/setup-python@v1" + uses: "actions/setup-python@v3" with: python-version: "${{ matrix.python-version }}" diff --git a/.gitignore b/.gitignore index 74d89080..93e7a2fc 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,3 @@ googlemaps.egg-info .vscode/ .idea/ index.py -test.py diff --git a/googlemaps/addressvalidation.py b/googlemaps/addressvalidation.py index 45b74655..149f3b48 100644 --- a/googlemaps/addressvalidation.py +++ b/googlemaps/addressvalidation.py @@ -1,5 +1,5 @@ # -# Copyright 2014 Google Inc. All rights reserved. +# Copyright 2022 Google Inc. All rights reserved. # # # Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -77,4 +77,5 @@ def addressvalidation(client, addressLines, regionCode=None , locality=None, ena return client._request("/v1:validateAddress", {}, # No GET params base_url=_ADDRESSVALIDATION_BASE_URL, extract_body=_addressvalidation_extract, - post_json=params) \ No newline at end of file + post_json=params) + \ No newline at end of file diff --git a/googlemaps/client.py b/googlemaps/client.py index 6684ed1e..301d6cab 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -180,7 +180,6 @@ def __init__(self, key=None, client_id=None, client_secret=None, "verify": True, # NOTE(cbro): verify SSL certs. }) - self.queries_quota : int self.queries_per_second = queries_per_second self.queries_per_minute = queries_per_minute try: diff --git a/tests/test_addressvalidation.py b/tests/test_addressvalidation.py index 69ad8b70..d1f2f589 100644 --- a/tests/test_addressvalidation.py +++ b/tests/test_addressvalidation.py @@ -26,7 +26,7 @@ class AddressValidationTest(TestCase): def setUp(self): - self.key = "AIzaasdf" + self.key = "AIzaSyD_sJl0qMA65CYHMBokVfMNA7AKyt5ERYs" self.client = googlemaps.Client(self.key) @responses.activate From c5982e7eadd8ded7bfcef862fa6182516125d19b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 21 Nov 2022 23:10:43 +0000 Subject: [PATCH 49/62] chore(release): 4.7.2 [skip ci] ## [4.7.2](https://github.com/googlemaps/google-maps-services-python/compare/v4.7.1...v4.7.2) (2022-11-21) ### Bug Fixes * fixes broken support for python 3.5 ([#453](https://github.com/googlemaps/google-maps-services-python/issues/453)) ([5b952d7](https://github.com/googlemaps/google-maps-services-python/commit/5b952d73f8374baac876b4d845fd46cebec6ed7e)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 226be765..ca3b7518 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.7.1" +__version__ = "4.7.2" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 053cd4d8..89c10a0f 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.7.1", + version="4.7.2", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From dcebf77cb8dc4e45a2bd8e95f8851d86811322a7 Mon Sep 17 00:00:00 2001 From: sandre35 <65041823+sandre35@users.noreply.github.com> Date: Tue, 22 Nov 2022 20:29:15 +0100 Subject: [PATCH 50/62] fix: correct lazy attribute inside logger (#457) --- googlemaps/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index 301d6cab..d1f4ab6a 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -191,7 +191,7 @@ def __init__(self, key=None, client_id=None, client_secret=None, self.queries_quota = math.floor(self.queries_per_minute/60) else: sys.exit("MISSING VALID NUMBER for queries_per_second or queries_per_minute") - logger.info("API queries_quota:", self.queries_quota) + logger.info("API queries_quota: %s", self.queries_quota) except NameError: sys.exit("MISSING VALUE for queries_per_second or queries_per_minute") From ca042f50ad8c2a68ed99dd89dad12bfe9b31cdf3 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 22 Nov 2022 19:30:32 +0000 Subject: [PATCH 51/62] chore(release): 4.7.3 [skip ci] ## [4.7.3](https://github.com/googlemaps/google-maps-services-python/compare/v4.7.2...v4.7.3) (2022-11-22) ### Bug Fixes * correct lazy attribute inside logger ([#457](https://github.com/googlemaps/google-maps-services-python/issues/457)) ([dcebf77](https://github.com/googlemaps/google-maps-services-python/commit/dcebf77cb8dc4e45a2bd8e95f8851d86811322a7)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index ca3b7518..f25d9359 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.7.2" +__version__ = "4.7.3" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 89c10a0f..239eceb0 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.7.2", + version="4.7.3", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 2c30f3a61d6632a6c7e7ec91718b97d6a1051379 Mon Sep 17 00:00:00 2001 From: Chris Arriola Date: Mon, 23 Jan 2023 15:09:05 -0800 Subject: [PATCH 52/62] docs: Adding docs.yml workflow to update docs on a new tag. (#360) * docs: Adding docs.yml workflow to update docs on a new tag. Once the docs have been generated, a new PR will be opened against the `gh-pages` branch. Resolves #348 Co-authored-by: Angela Yu <5506675+wangela@users.noreply.github.com> --- .github/workflows/docs.yml | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..c83d6c38 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,63 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A workflow that pushes artifacts to Sonatype +name: Publish + +on: + push: + tags: + - '*' + repository_dispatch: + types: [docs] + +jobs: + docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: "actions/setup-python@v3" + with: + python-version: "3.9" + + - name: Install dependencies + run: ./.github/scripts/install.sh + + - name: Generate docs + run: python3 -m nox --session docs + + - name: Update gh-pages branch with docs + run: | + echo "Creating tar for generated docs" + cd ./docs/_build/html && tar cvf ~/docs.tar . + + echo "Unpacking tar into gh-pages branch" + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + cd $GITHUB_WORKSPACE && git checkout gh-pages && tar xvf ~/docs.tar + + - name: PR Changes + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} + commit-message: 'docs: Update docs' + committer: googlemaps-bot + author: googlemaps-bot + title: 'docs: Update docs' + body: | + Updated GitHub pages with latest from `python3 -m nox --session docs`. + branch: googlemaps-bot/update_gh_pages From 88268363f4612fa97a525c149f7dce3e36f293ef Mon Sep 17 00:00:00 2001 From: Angela Yu <5506675+wangela@users.noreply.github.com> Date: Mon, 23 Jan 2023 23:34:06 -0800 Subject: [PATCH 53/62] chore: update release action dependencies (#473) * chore: update release action dependencies * chore: set semantic release version --- .github/workflows/release.yml | 7 ++++--- .github/workflows/test.yml | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce78e642..a0a28dce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,11 +23,11 @@ jobs: PYTHONDONTWRITEBYTECODE: 1 steps: - name: Setup Python - uses: "actions/setup-python@v1" + uses: "actions/setup-python@v3" with: python-version: "3.9" - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} - name: Install dependencies @@ -37,8 +37,9 @@ jobs: - name: Cleanup old dist run: rm -rf googlemaps-* dist/ - name: Semantic Release - uses: cycjimmy/semantic-release-action@v2 + uses: cycjimmy/semantic-release-action@v3 with: + semantic_version: 19 extra_plugins: | "@semantic-release/commit-analyzer" "@semantic-release/release-notes-generator" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 286ff75a..570a087a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -51,4 +51,6 @@ jobs: needs: [matrix] runs-on: ubuntu-latest steps: - - run: echo "Test matrix finished" + - run: | + echo "Test matrix finished"; + exit 0; From 9f09ccbaecef7c1244f07f8cccc39024ad5fddee Mon Sep 17 00:00:00 2001 From: Joe Loffredo <60896458+jloffredo2@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:11:59 -0500 Subject: [PATCH 54/62] feat: add `editorial_summary` to Place Details atmosphere fields (#472) --- googlemaps/places.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/places.py b/googlemaps/places.py index 91c14dfe..ac3bf53e 100644 --- a/googlemaps/places.py +++ b/googlemaps/places.py @@ -80,7 +80,7 @@ PLACES_DETAIL_FIELDS_CONTACT = {"formatted_phone_number", "international_phone_number", "opening_hours", "website"} -PLACES_DETAIL_FIELDS_ATMOSPHERE = {"price_level", "rating", "review", "user_ratings_total"} +PLACES_DETAIL_FIELDS_ATMOSPHERE = {"editorial_summary","price_level", "rating", "review", "user_ratings_total"} PLACES_DETAIL_FIELDS = ( PLACES_DETAIL_FIELDS_BASIC From 65d5a263e683e3763a6e1c076d1c5778211fd745 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 24 Jan 2023 19:13:04 +0000 Subject: [PATCH 55/62] chore(release): 4.8.0 [skip ci] # [4.8.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.7.3...v4.8.0) (2023-01-24) ### Features * add `editorial_summary` to Place Details atmosphere fields ([#472](https://github.com/googlemaps/google-maps-services-python/issues/472)) ([9f09ccb](https://github.com/googlemaps/google-maps-services-python/commit/9f09ccbaecef7c1244f07f8cccc39024ad5fddee)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index f25d9359..be61bb0e 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.7.3" +__version__ = "4.8.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 239eceb0..3958aed2 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.7.3", + version="4.8.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 8afe62898f1733316fea705e8daa0313add7b93c Mon Sep 17 00:00:00 2001 From: nnolan <36713193+nnolan@users.noreply.github.com> Date: Tue, 24 Jan 2023 16:23:43 -0600 Subject: [PATCH 56/62] feat: add support for sorting reviews in Place Details requests (#468) --- googlemaps/places.py | 16 ++++++++++++++-- tests/test_places.py | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/googlemaps/places.py b/googlemaps/places.py index ac3bf53e..35b818f2 100644 --- a/googlemaps/places.py +++ b/googlemaps/places.py @@ -396,7 +396,14 @@ def _places( return client._request(url, params) -def place(client, place_id, session_token=None, fields=None, language=None): +def place( + client, + place_id, + session_token=None, + fields=None, + language=None, + reviews_sort="most_relevant" +): """ Comprehensive details for an individual place. @@ -416,6 +423,10 @@ def place(client, place_id, session_token=None, fields=None, language=None): :param language: The language in which to return results. :type language: string + :param reviews_sort: The sorting method to use when returning reviews. + Can be set to most_relevant (default) or newest. + :type reviews_sort: string + :rtype: result dict with the following keys: result: dict containing place details html_attributions: set of attributions which must be displayed @@ -444,6 +455,8 @@ def place(client, place_id, session_token=None, fields=None, language=None): params["language"] = language if session_token: params["sessiontoken"] = session_token + if reviews_sort: + params["reviews_sort"] = reviews_sort return client._request("/maps/api/place/details/json", params) @@ -657,4 +670,3 @@ def _autocomplete( url = "/maps/api/place/%sautocomplete/json" % url_part return client._request(url, params).get("predictions", []) - \ No newline at end of file diff --git a/tests/test_places.py b/tests/test_places.py index 50781773..dd29935d 100644 --- a/tests/test_places.py +++ b/tests/test_places.py @@ -36,6 +36,7 @@ def setUp(self): self.type = "liquor_store" self.language = "en-AU" self.region = "AU" + self.reviews_sort="newest" self.radius = 100 @responses.activate @@ -165,11 +166,12 @@ def test_place_detail(self): "ChIJN1t_tDeuEmsRUsoyG83frY4", fields=["business_status", "geometry/location", "place_id"], language=self.language, + reviews_sort=self.reviews_sort, ) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "%s?language=en-AU&placeid=ChIJN1t_tDeuEmsRUsoyG83frY4" + "%s?reviews_sort=newest&language=en-AU&placeid=ChIJN1t_tDeuEmsRUsoyG83frY4" "&key=%s&fields=business_status,geometry/location,place_id" % (url, self.key), responses.calls[0].request.url, From 72c482c78d1cbb86eb9847e09e0976b16c0f49a6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 24 Jan 2023 22:24:47 +0000 Subject: [PATCH 57/62] chore(release): 4.9.0 [skip ci] # [4.9.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.8.0...v4.9.0) (2023-01-24) ### Features * add support for sorting reviews in Place Details requests ([#468](https://github.com/googlemaps/google-maps-services-python/issues/468)) ([8afe628](https://github.com/googlemaps/google-maps-services-python/commit/8afe62898f1733316fea705e8daa0313add7b93c)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index be61bb0e..6aabb596 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.8.0" +__version__ = "4.9.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 3958aed2..634cfb42 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.8.0", + version="4.9.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 6c69310997e2e82edb5ee3e7235a3057945e7c76 Mon Sep 17 00:00:00 2001 From: Angela Yu <5506675+wangela@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:43:40 -0800 Subject: [PATCH 58/62] feat: add new place details fields and reviews request modifiers (#474) * feat: add new place details fields and support for reviews sorting and translation * feat: support reviews (plural) field --- googlemaps/places.py | 97 ++++++++++++++++++++++++++++++-------------- tests/test_places.py | 12 +++--- 2 files changed, 73 insertions(+), 36 deletions(-) diff --git a/googlemaps/places.py b/googlemaps/places.py index 35b818f2..269a17fa 100644 --- a/googlemaps/places.py +++ b/googlemaps/places.py @@ -52,35 +52,64 @@ ^ PLACES_FIND_FIELDS_ATMOSPHERE ) -PLACES_DETAIL_FIELDS_BASIC = {"address_component", - "adr_address", - "business_status", - "formatted_address", - "geometry", - "geometry/location", - "geometry/location/lat", - "geometry/location/lng", - "geometry/viewport", - "geometry/viewport/northeast", - "geometry/viewport/northeast/lat", - "geometry/viewport/northeast/lng", - "geometry/viewport/southwest", - "geometry/viewport/southwest/lat", - "geometry/viewport/southwest/lng", - "icon", - "name", - "permanently_closed", - "photo", - "place_id", - "plus_code", - "type", - "url", - "utc_offset", - "vicinity",} - -PLACES_DETAIL_FIELDS_CONTACT = {"formatted_phone_number", "international_phone_number", "opening_hours", "website"} - -PLACES_DETAIL_FIELDS_ATMOSPHERE = {"editorial_summary","price_level", "rating", "review", "user_ratings_total"} +PLACES_DETAIL_FIELDS_BASIC = { + "address_component", + "adr_address", + "business_status", + "formatted_address", + "geometry", + "geometry/location", + "geometry/location/lat", + "geometry/location/lng", + "geometry/viewport", + "geometry/viewport/northeast", + "geometry/viewport/northeast/lat", + "geometry/viewport/northeast/lng", + "geometry/viewport/southwest", + "geometry/viewport/southwest/lat", + "geometry/viewport/southwest/lng", + "icon", + "name", + "permanently_closed", + "photo", + "place_id", + "plus_code", + "type", + "url", + "utc_offset", + "vicinity", + "wheelchair_accessible_entrance" +} + +PLACES_DETAIL_FIELDS_CONTACT = { + "formatted_phone_number", + "international_phone_number", + "opening_hours", + "current_opening_hours", + "secondary_opening_hours", + "website", +} + +PLACES_DETAIL_FIELDS_ATMOSPHERE = { + "curbside_pickup", + "delivery", + "dine_in", + "editorial_summary", + "price_level", + "rating", + "reservable", + "review", # prefer "reviews" to match API documentation + "reviews", + "serves_beer", + "serves_breakfast", + "serves_brunch", + "serves_dinner", + "serves_lunch", + "serves_vegetarian_food", + "serves_wine", + "takeout", + "user_ratings_total" +} PLACES_DETAIL_FIELDS = ( PLACES_DETAIL_FIELDS_BASIC @@ -88,7 +117,7 @@ ^ PLACES_DETAIL_FIELDS_ATMOSPHERE ) -DEPRECATED_FIELDS = {"permanently_closed"} +DEPRECATED_FIELDS = {"permanently_closed", "review"} DEPRECATED_FIELDS_MESSAGE = ( "Fields, %s, are deprecated. " "Read more at https://developers.google.com/maps/deprecations." @@ -402,7 +431,8 @@ def place( session_token=None, fields=None, language=None, - reviews_sort="most_relevant" + reviews_no_translations=False, + reviews_sort="most_relevant", ): """ Comprehensive details for an individual place. @@ -423,6 +453,9 @@ def place( :param language: The language in which to return results. :type language: string + :param reviews_no_translations: Specify reviews_no_translations=True to disable translation of reviews; reviews_no_translations=False (default) enables translation of reviews. + :type reviews_no_translations: bool + :param reviews_sort: The sorting method to use when returning reviews. Can be set to most_relevant (default) or newest. :type reviews_sort: string @@ -455,6 +488,8 @@ def place( params["language"] = language if session_token: params["sessiontoken"] = session_token + if reviews_no_translations: + params["reviews_no_translations"] = "true" if reviews_sort: params["reviews_sort"] = reviews_sort diff --git a/tests/test_places.py b/tests/test_places.py index dd29935d..32f03d16 100644 --- a/tests/test_places.py +++ b/tests/test_places.py @@ -36,7 +36,6 @@ def setUp(self): self.type = "liquor_store" self.language = "en-AU" self.region = "AU" - self.reviews_sort="newest" self.radius = 100 @responses.activate @@ -164,15 +163,18 @@ def test_place_detail(self): self.client.place( "ChIJN1t_tDeuEmsRUsoyG83frY4", - fields=["business_status", "geometry/location", "place_id"], + fields=["business_status", "geometry/location", + "place_id", "reviews"], language=self.language, - reviews_sort=self.reviews_sort, + reviews_no_translations=True, + reviews_sort="newest", ) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "%s?reviews_sort=newest&language=en-AU&placeid=ChIJN1t_tDeuEmsRUsoyG83frY4" - "&key=%s&fields=business_status,geometry/location,place_id" + "%s?language=en-AU&placeid=ChIJN1t_tDeuEmsRUsoyG83frY4" + "&reviews_no_translations=true&reviews_sort=newest" + "&key=%s&fields=business_status,geometry/location,place_id,reviews" % (url, self.key), responses.calls[0].request.url, ) From 82674b7fccb00d611f36b11cab6f281827174f8b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 26 Jan 2023 16:44:56 +0000 Subject: [PATCH 59/62] chore(release): 4.10.0 [skip ci] # [4.10.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.9.0...v4.10.0) (2023-01-26) ### Features * add new place details fields and reviews request modifiers ([#474](https://github.com/googlemaps/google-maps-services-python/issues/474)) ([6c69310](https://github.com/googlemaps/google-maps-services-python/commit/6c69310997e2e82edb5ee3e7235a3057945e7c76)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index 6aabb596..61ec45d0 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.9.0" +__version__ = "4.10.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index 634cfb42..df9f32f1 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.9.0", + version="4.10.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown", From 80cb54e16964e686d24cfd536ab8db329395e274 Mon Sep 17 00:00:00 2001 From: Angela Yu <5506675+wangela@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:52:42 -0800 Subject: [PATCH 60/62] chore: update nox docs python version --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 2bc3b2a1..e5b92961 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,7 +52,7 @@ def cover(session): session.run("coverage", "erase") -@nox.session(python="3.6") +@nox.session(python="3.7") def docs(session): _install_dev_packages(session) _install_doc_dependencies(session) From 645e07de5a27c4c858b2c0673f0dd6f23ca62d28 Mon Sep 17 00:00:00 2001 From: Angela Yu <5506675+wangela@users.noreply.github.com> Date: Thu, 26 Jan 2023 17:01:18 -0800 Subject: [PATCH 61/62] docs: fix code format in static maps docs (#475) --- googlemaps/maps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/googlemaps/maps.py b/googlemaps/maps.py index cc1a054e..746223d6 100644 --- a/googlemaps/maps.py +++ b/googlemaps/maps.py @@ -123,7 +123,7 @@ def __init__(self, points, def static_map(client, size, - center=None, zoom=None, scale=None, + center=None, zoom=None, scale=None, format=None, maptype=None, language=None, region=None, markers=None, path=None, visible=None, style=None): """ @@ -181,7 +181,8 @@ def static_map(client, size, :rtype: iterator containing the raw image data, which typically can be used to save an image file locally. For example: - ``` + .. code-block:: python + f = open(local_filename, 'wb') for chunk in client.static_map(size=(400, 400), center=(52.520103, 13.404871), @@ -189,7 +190,6 @@ def static_map(client, size, if chunk: f.write(chunk) f.close() - ``` """ params = {"size": convert.size(size)} From 9ec69cb66eec929d08ca90a82081b8ee4eef8b54 Mon Sep 17 00:00:00 2001 From: Thomas Clifford Date: Tue, 16 Jul 2024 10:47:22 -0700 Subject: [PATCH 62/62] =?UTF-8?q?feat!:=20Added=20Address=20Descriptors=20?= =?UTF-8?q?to=20Geocoding=20response.=20Refactored=20Geo=E2=80=A6=20(#516)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat! Added Address Descriptors to Geocoding response. Refactored Geocoding response to allow fields outside the geocoding result to be exposed through the client. --------- Co-authored-by: Tom Clifford --- README.md | 4 +++ googlemaps/geocoding.py | 18 ++++++++++---- tests/test_geocoding.py | 54 +++++++++++++++++++++++++++++------------ 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index cb5f7821..40823790 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'], regionCode='US', locality='Mountain View', enableUspsCass=True) + +# Get an Address Descriptor of a location in the reverse geocoding response +address_descriptor_result = gmaps.reverse_geocode((40.714224, -73.961452), enable_address_descriptor=True) + ``` For more usage examples, check out [the tests](https://github.com/googlemaps/google-maps-services-python/tree/master/tests). diff --git a/googlemaps/geocoding.py b/googlemaps/geocoding.py index e409a49e..590bb627 100644 --- a/googlemaps/geocoding.py +++ b/googlemaps/geocoding.py @@ -49,7 +49,9 @@ def geocode(client, address=None, place_id=None, components=None, bounds=None, r :param language: The language in which to return results. :type language: string - :rtype: list of geocoding results. + :rtype: result dict with the following keys: + status: status code + results: list of geocoding results """ params = {} @@ -72,11 +74,11 @@ def geocode(client, address=None, place_id=None, components=None, bounds=None, r if language: params["language"] = language - return client._request("/maps/api/geocode/json", params).get("results", []) + return client._request("/maps/api/geocode/json", params) def reverse_geocode(client, latlng, result_type=None, location_type=None, - language=None): + language=None, enable_address_descriptor=False): """ Reverse geocoding is the process of converting geographic coordinates into a human-readable address. @@ -94,7 +96,10 @@ def reverse_geocode(client, latlng, result_type=None, location_type=None, :param language: The language in which to return results. :type language: string - :rtype: list of reverse geocoding results. + :rtype: result dict with the following keys: + status: status code + results: list of reverse geocoding results + address_descriptor: address descriptor for the target """ # Check if latlng param is a place_id string. @@ -113,4 +118,7 @@ def reverse_geocode(client, latlng, result_type=None, location_type=None, if language: params["language"] = language - return client._request("/maps/api/geocode/json", params).get("results", []) + if enable_address_descriptor: + params["enable_address_descriptor"] = "true" + + return client._request("/maps/api/geocode/json", params) diff --git a/tests/test_geocoding.py b/tests/test_geocoding.py index 813241f6..8734c8b8 100644 --- a/tests/test_geocoding.py +++ b/tests/test_geocoding.py @@ -41,7 +41,7 @@ def test_simple_geocode(self): content_type="application/json", ) - results = self.client.geocode("Sydney") + results = self.client.geocode("Sydney").get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -60,7 +60,7 @@ def test_reverse_geocode(self): content_type="application/json", ) - results = self.client.reverse_geocode((-33.8674869, 151.2069902)) + results = self.client.reverse_geocode((-33.8674869, 151.2069902)).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -79,7 +79,7 @@ def test_geocoding_the_googleplex(self): content_type="application/json", ) - results = self.client.geocode("1600 Amphitheatre Parkway, " "Mountain View, CA") + results = self.client.geocode("1600 Amphitheatre Parkway, " "Mountain View, CA").get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -105,7 +105,7 @@ def test_geocode_with_bounds(self): "southwest": (34.172684, -118.604794), "northeast": (34.236144, -118.500938), }, - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -125,7 +125,7 @@ def test_geocode_with_region_biasing(self): content_type="application/json", ) - results = self.client.geocode("Toledo", region="es") + results = self.client.geocode("Toledo", region="es").get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -144,7 +144,7 @@ def test_geocode_with_component_filter(self): content_type="application/json", ) - results = self.client.geocode("santa cruz", components={"country": "ES"}) + results = self.client.geocode("santa cruz", components={"country": "ES"}).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -165,7 +165,7 @@ def test_geocode_with_multiple_component_filters(self): results = self.client.geocode( "Torun", components={"administrative_area": "TX", "country": "US"} - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -191,7 +191,7 @@ def test_geocode_with_just_components(self): "administrative_area": "Helsinki", "country": "Finland", } - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -211,7 +211,7 @@ def test_geocode_place_id(self): content_type="application/json", ) - results = self.client.geocode(place_id="ChIJeRpOeF67j4AR9ydy_PIzPuM") + results = self.client.geocode(place_id="ChIJeRpOeF67j4AR9ydy_PIzPuM").get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -230,7 +230,7 @@ def test_simple_reverse_geocode(self): content_type="application/json", ) - results = self.client.reverse_geocode((40.714224, -73.961452)) + results = self.client.reverse_geocode((40.714224, -73.961452)).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -253,7 +253,7 @@ def test_reverse_geocode_restricted_by_type(self): (40.714224, -73.961452), location_type="ROOFTOP", result_type="street_address", - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -277,7 +277,7 @@ def test_reverse_geocode_multiple_location_types(self): (40.714224, -73.961452), location_type=["ROOFTOP", "RANGE_INTERPOLATED"], result_type="street_address", - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -301,7 +301,7 @@ def test_reverse_geocode_multiple_result_types(self): (40.714224, -73.961452), location_type="ROOFTOP", result_type=["street_address", "route"], - ) + ).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -311,6 +311,28 @@ def test_reverse_geocode_multiple_result_types(self): responses.calls[0].request.url, ) + @responses.activate + def test_reverse_geocode_with_address_descriptors(self): + responses.add( + responses.GET, + "https://maps.googleapis.com/maps/api/geocode/json", + body='{"status":"OK","results":[], "address_descriptor":{ "landmarks": [ { "placeId": "id" } ] } }', + status=200, + content_type="application/json", + ) + + response = self.client.reverse_geocode((-33.8674869, 151.2069902), enable_address_descriptor=True) + + address_descriptor = response.get("address_descriptor", []) + + self.assertEqual(1, len(address_descriptor["landmarks"])) + self.assertEqual(1, len(responses.calls)) + self.assertURLEqual( + "https://maps.googleapis.com/maps/api/geocode/json?" + "latlng=-33.8674869,151.2069902&enable_address_descriptor=true&key=%s" % self.key, + responses.calls[0].request.url, + ) + @responses.activate def test_partial_match(self): responses.add( @@ -321,7 +343,7 @@ def test_partial_match(self): content_type="application/json", ) - results = self.client.geocode("Pirrama Pyrmont") + results = self.client.geocode("Pirrama Pyrmont").get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -340,7 +362,7 @@ def test_utf_results(self): content_type="application/json", ) - results = self.client.geocode(components={"postal_code": "96766"}) + results = self.client.geocode(components={"postal_code": "96766"}).get("results", []) self.assertEqual(1, len(responses.calls)) self.assertURLEqual( @@ -359,7 +381,7 @@ def test_utf8_request(self): content_type="application/json", ) - self.client.geocode(self.u("\\u4e2d\\u56fd")) # China + self.client.geocode(self.u("\\u4e2d\\u56fd")).get("results", []) # China self.assertURLEqual( "https://maps.googleapis.com/maps/api/geocode/json?" "key=%s&address=%s" % (self.key, "%E4%B8%AD%E5%9B%BD"),