Skip to content

Commit 60dc200

Browse files
fix: Python 3.8 support (#1918)
There were recently some type annotation changes that weren't compatible with python 3.8. This PR fixes those, and adds back 3.8 tests using github actions --------- Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 5c07e1c commit 60dc200

File tree

4 files changed

+89
-7
lines changed

4 files changed

+89
-7
lines changed

.github/workflows/unittest.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
on:
16+
pull_request:
17+
branches:
18+
- main
19+
20+
permissions:
21+
contents: read
22+
23+
name: unittest
24+
jobs:
25+
unit:
26+
runs-on: ubuntu-22.04
27+
strategy:
28+
matrix:
29+
python: ['3.8']
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
- name: Setup Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ matrix.python }}
37+
- name: Install nox
38+
run: |
39+
python -m pip install --upgrade setuptools pip wheel
40+
python -m pip install nox
41+
- name: Run unit tests
42+
env:
43+
COVERAGE_FILE: .coverage-${{ matrix.python }}
44+
run: |
45+
nox -s unit-${{ matrix.python }}
46+
- name: Upload coverage results
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: coverage-artifact-${{ matrix.python }}
50+
path: .coverage-${{ matrix.python }}
51+
include-hidden-files: true
52+
53+
cover:
54+
runs-on: ubuntu-latest
55+
needs:
56+
- unit
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
- name: Setup Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: "3.13"
64+
- name: Install coverage
65+
run: |
66+
python -m pip install --upgrade setuptools pip wheel
67+
python -m pip install coverage
68+
- name: Download coverage results
69+
uses: actions/download-artifact@v4
70+
with:
71+
path: .coverage-results/
72+
- name: Report coverage results
73+
run: |
74+
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
75+
coverage combine .coverage-results/**/.coverage*
76+
coverage report --show-missing --fail-under=99

google/auth/_default.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
1717
Implements application default credentials and project ID detection.
1818
"""
19+
from __future__ import annotations
1920

20-
from collections.abc import Sequence
2121
import io
2222
import json
2323
import logging
2424
import os
25-
from typing import Optional, TYPE_CHECKING
25+
from typing import Optional, Sequence, TYPE_CHECKING
2626
import warnings
2727

2828
from google.auth import environment_vars

google/oauth2/id_token.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
http://openid.net/specs/openid-connect-core-1_0.html#IDToken
5555
.. _CacheControl: https://cachecontrol.readthedocs.io
5656
"""
57+
from __future__ import annotations
5758

5859
import http.client as http_client
5960
import json

noxfile.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@
3232
]
3333

3434
DEFAULT_PYTHON_VERSION = "3.14"
35-
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1787):
36-
# Remove or restore testing for Python 3.7/3.8
37-
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
35+
UNIT_TEST_PYTHON_VERSIONS = [
36+
"3.7",
37+
"3.8",
38+
"3.9",
39+
"3.10",
40+
"3.11",
41+
"3.12",
42+
"3.13",
43+
"3.14",
44+
]
3845

3946
# Error if a python version is missing
4047
nox.options.error_on_missing_interpreters = True
@@ -44,8 +51,6 @@
4451
"lint",
4552
"blacken",
4653
"mypy",
47-
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1787):
48-
# Remove or restore testing for Python 3.7/3.8
4954
"unit-3.9",
5055
"unit-3.10",
5156
"unit-3.11",

0 commit comments

Comments
 (0)