From 7d3d877055d2079974d362d0c59580905ddfb58e Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 08:51:37 -0800 Subject: [PATCH 01/15] import sequence from typing --- google/auth/_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/auth/_default.py b/google/auth/_default.py index d854163c4..b734cc75b 100644 --- a/google/auth/_default.py +++ b/google/auth/_default.py @@ -17,7 +17,7 @@ Implements application default credentials and project ID detection. """ -from collections.abc import Sequence +from typing import Sequence import io import json import logging From 1e98bc1788ef796ce87512cb21d1b3818c7abff3 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 08:52:34 -0800 Subject: [PATCH 02/15] add 3.7 and 3.8 to unit tests --- noxfile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 8a97f74cd..5a019a979 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,9 +32,7 @@ ] DEFAULT_PYTHON_VERSION = "3.14" -# TODO(https://github.com/googleapis/google-auth-library-python/issues/1787): -# Remove or restore testing for Python 3.7/3.8 -UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] +UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] # Error if a python version is missing nox.options.error_on_missing_interpreters = True From 0d4111537892da28fad879314a3089a822216b6b Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:00:05 -0800 Subject: [PATCH 03/15] added nox session --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 5a019a979..4890d43c6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -42,8 +42,8 @@ "lint", "blacken", "mypy", - # TODO(https://github.com/googleapis/google-auth-library-python/issues/1787): - # Remove or restore testing for Python 3.7/3.8 + "unit-3.7", + "unit-3.8", "unit-3.9", "unit-3.10", "unit-3.11", From 4f4db7be5a6c9e0773f23f79fd0bcaff8ab666ae Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:40:49 -0800 Subject: [PATCH 04/15] added github actions --- .github/workflows/unittest.yml | 58 ++++++++++++++++++++++++++++++++++ noxfile.py | 2 -- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/unittest.yml diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 000000000..3de1fa75e --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,58 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-22.04 + strategy: + matrix: + python: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v4 + with: + name: coverage-artifact-${{ matrix.python }} + path: .coverage-${{ matrix.python }} + include-hidden-files: true + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v4 + with: + path: .coverage-results/ + - name: Report coverage results + run: | + find .coverage-results -type f -name '*.zip' -exec unzip {} \; + coverage combine .coverage-results/**/.coverage* + coverage report --show-missing --fail-under=99 diff --git a/noxfile.py b/noxfile.py index 4890d43c6..4a851967b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -42,8 +42,6 @@ "lint", "blacken", "mypy", - "unit-3.7", - "unit-3.8", "unit-3.9", "unit-3.10", "unit-3.11", From 31ba7efd842b7378eec40bdb65396dfe0b187119 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:43:22 -0800 Subject: [PATCH 05/15] added annotations --- .github/workflows/unittest.yml | 2 +- google/auth/_default.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 3de1fa75e..6b6ee237b 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + python: ['3.7', '3.8'] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/google/auth/_default.py b/google/auth/_default.py index b734cc75b..4877d7b1f 100644 --- a/google/auth/_default.py +++ b/google/auth/_default.py @@ -16,6 +16,7 @@ Implements application default credentials and project ID detection. """ +from __future__ import annotations from typing import Sequence import io From 31c434602ccaa59ba97265df4a7f631bd9da0a12 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:46:06 -0800 Subject: [PATCH 06/15] added extra annotations import --- google/oauth2/id_token.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/oauth2/id_token.py b/google/oauth2/id_token.py index fe4bebd78..d21be1a06 100644 --- a/google/oauth2/id_token.py +++ b/google/oauth2/id_token.py @@ -54,6 +54,7 @@ http://openid.net/specs/openid-connect-core-1_0.html#IDToken .. _CacheControl: https://cachecontrol.readthedocs.io """ +from __future__ import annotations import http.client as http_client import json From 1aa5bb7fe37fd5a66c9c979de0d9a42e091630c9 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:49:54 -0800 Subject: [PATCH 07/15] support AsyncMock on 3.7 --- tests/transport/aio/test_aiohttp.py | 7 ++++++- tests_async/oauth2/test_reauth_async.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/transport/aio/test_aiohttp.py b/tests/transport/aio/test_aiohttp.py index 13f86ba34..07791fc8f 100644 --- a/tests/transport/aio/test_aiohttp.py +++ b/tests/transport/aio/test_aiohttp.py @@ -13,7 +13,12 @@ # limitations under the License. import asyncio -from unittest.mock import AsyncMock, Mock, patch +from unittest.mock import Mock, patch +try: + from unittest.mock import AsyncMock +except ImportError: + # Fallback for Python < 3.8 + from mock import AsyncMock from aioresponses import aioresponses # type: ignore import pytest # type: ignore diff --git a/tests_async/oauth2/test_reauth_async.py b/tests_async/oauth2/test_reauth_async.py index 4874a3728..a2c80471f 100644 --- a/tests_async/oauth2/test_reauth_async.py +++ b/tests_async/oauth2/test_reauth_async.py @@ -14,6 +14,11 @@ import copy from unittest import mock +try: + from unittest.mock import AsyncMock +except ImportError: + # Fallback for Python < 3.8 + from mock import AsyncMock import pytest # type: ignore @@ -22,7 +27,7 @@ from google.oauth2 import reauth -MOCK_REQUEST = mock.AsyncMock(spec=["transport.Request"]) +MOCK_REQUEST = AsyncMock(spec=["transport.Request"]) CHALLENGES_RESPONSE_TEMPLATE = { "status": "CHALLENGE_REQUIRED", "sessionId": "123", From 8a1444a9b01e34c9d393a8dd563ff1fbc13eab3f Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:52:30 -0800 Subject: [PATCH 08/15] adding mock to constraints file --- testing/constraints-3.7.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 52ad3af91..b07e00fc3 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -10,4 +10,5 @@ setuptools==40.3.0 rsa==3.1.4 aiohttp==3.6.2 requests==2.20.0 -pyjwt==2.0 \ No newline at end of file +pyjwt==2.0 +mock==5.2.0 From 649855ab2c7e8e3dc21b5ce387d035e81ce17758 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 09:55:46 -0800 Subject: [PATCH 09/15] add mock to testing extras --- setup.py | 1 + testing/constraints-3.7.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3db2d8cf9..4ee234fc2 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,7 @@ # TODO(https://github.com/googleapis/google-auth-library-python/issues/1722): `test_aiohttp_requests` depend on # aiohttp < 3.10.0 which is a bug. Investigate and remove the pinned aiohttp version. "aiohttp < 3.10.0", + "mock; python_version < '3.8'", ] extras = { diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index b07e00fc3..c5c53dbbe 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -11,4 +11,3 @@ rsa==3.1.4 aiohttp==3.6.2 requests==2.20.0 pyjwt==2.0 -mock==5.2.0 From 8a082c9e68d25d6228d6da90d175358f25e3af62 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 10:00:42 -0800 Subject: [PATCH 10/15] remove 3.7 from tests --- .github/workflows/unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 6b6ee237b..ab21829d1 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python: ['3.7', '3.8'] + python: ['3.8'] steps: - name: Checkout uses: actions/checkout@v4 From 3322dfea0909fbd08ee2d6e467d0f9cd12ff5640 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 10:06:21 -0800 Subject: [PATCH 11/15] revert 3.7 changes --- setup.py | 1 - testing/constraints-3.7.txt | 2 +- tests/transport/aio/test_aiohttp.py | 7 +------ tests_async/oauth2/test_reauth_async.py | 7 +------ 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index 4ee234fc2..3db2d8cf9 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,6 @@ # TODO(https://github.com/googleapis/google-auth-library-python/issues/1722): `test_aiohttp_requests` depend on # aiohttp < 3.10.0 which is a bug. Investigate and remove the pinned aiohttp version. "aiohttp < 3.10.0", - "mock; python_version < '3.8'", ] extras = { diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index c5c53dbbe..52ad3af91 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -10,4 +10,4 @@ setuptools==40.3.0 rsa==3.1.4 aiohttp==3.6.2 requests==2.20.0 -pyjwt==2.0 +pyjwt==2.0 \ No newline at end of file diff --git a/tests/transport/aio/test_aiohttp.py b/tests/transport/aio/test_aiohttp.py index 07791fc8f..13f86ba34 100644 --- a/tests/transport/aio/test_aiohttp.py +++ b/tests/transport/aio/test_aiohttp.py @@ -13,12 +13,7 @@ # limitations under the License. import asyncio -from unittest.mock import Mock, patch -try: - from unittest.mock import AsyncMock -except ImportError: - # Fallback for Python < 3.8 - from mock import AsyncMock +from unittest.mock import AsyncMock, Mock, patch from aioresponses import aioresponses # type: ignore import pytest # type: ignore diff --git a/tests_async/oauth2/test_reauth_async.py b/tests_async/oauth2/test_reauth_async.py index a2c80471f..4874a3728 100644 --- a/tests_async/oauth2/test_reauth_async.py +++ b/tests_async/oauth2/test_reauth_async.py @@ -14,11 +14,6 @@ import copy from unittest import mock -try: - from unittest.mock import AsyncMock -except ImportError: - # Fallback for Python < 3.8 - from mock import AsyncMock import pytest # type: ignore @@ -27,7 +22,7 @@ from google.oauth2 import reauth -MOCK_REQUEST = AsyncMock(spec=["transport.Request"]) +MOCK_REQUEST = mock.AsyncMock(spec=["transport.Request"]) CHALLENGES_RESPONSE_TEMPLATE = { "status": "CHALLENGE_REQUIRED", "sessionId": "123", From 1211004ea82b4059598748fcb343c0bef1677d06 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 10:42:36 -0800 Subject: [PATCH 12/15] fixed lint --- noxfile.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 4a851967b..70173e55c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,7 +32,16 @@ ] DEFAULT_PYTHON_VERSION = "3.14" -UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] +UNIT_TEST_PYTHON_VERSIONS = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", + "3.14", +] # Error if a python version is missing nox.options.error_on_missing_interpreters = True From 5b78fa30c8d12f615a52f9397a218d58128a575f Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 11:10:04 -0800 Subject: [PATCH 13/15] fixed lint --- google/auth/_default.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/google/auth/_default.py b/google/auth/_default.py index 4877d7b1f..01bd02a21 100644 --- a/google/auth/_default.py +++ b/google/auth/_default.py @@ -18,12 +18,11 @@ """ from __future__ import annotations -from typing import Sequence import io import json import logging import os -from typing import Optional, TYPE_CHECKING +from typing import Optional, Sequence, TYPE_CHECKING import warnings from google.auth import environment_vars From 9dce704b0f27e665e4d71430da0efa0defc3f353 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 11:43:30 -0800 Subject: [PATCH 14/15] Update .github/workflows/unittest.yml Co-authored-by: Anthonios Partheniou --- .github/workflows/unittest.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index ab21829d1..e8c51cbea 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -2,6 +2,10 @@ on: pull_request: branches: - main + +permissions: + contents: read + name: unittest jobs: unit: From a48ccda531f3977ec54f800f79368549c7c1bb40 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 6 Jan 2026 11:44:32 -0800 Subject: [PATCH 15/15] add copyright header --- .github/workflows/unittest.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index e8c51cbea..a5ddd035d 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -1,3 +1,17 @@ +# Copyright 2026 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 +# +# https://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. + on: pull_request: branches: