Skip to content

Commit 063991a

Browse files
committed
chore: Simplify code intended for Python 3.9+
1 parent d91d4b1 commit 063991a

File tree

6 files changed

+8
-29
lines changed

6 files changed

+8
-29
lines changed

.kokoro/test-samples-impl.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ export PYTHONUNBUFFERED=1
3333
env | grep KOKORO
3434

3535
# Install nox
36-
# `virtualenv==20.26.6` is added for Python 3.7 compatibility
37-
python3.9 -m pip install --upgrade --quiet nox virtualenv==20.26.6
36+
python3.9 -m pip install --upgrade --quiet nox
3837

3938
# Use secrets acessor service account to get secrets
4039
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then

CONTRIBUTING.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ In order to add a feature:
2121
documentation.
2222

2323
- The feature must work fully on the following CPython versions:
24-
3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on both UNIX and Windows.
24+
3.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on both UNIX and Windows.
2525

2626
- The feature must not add unnecessary dependencies (where
2727
"unnecessary" is of course subjective, but new dependencies should
@@ -197,17 +197,13 @@ Supported Python Versions
197197

198198
We support:
199199

200-
- `Python 3.7`_
201-
- `Python 3.8`_
202200
- `Python 3.9`_
203201
- `Python 3.10`_
204202
- `Python 3.11`_
205203
- `Python 3.12`_
206204
- `Python 3.13`_
207205
- `Python 3.14`_
208206

209-
.. _Python 3.7: https://docs.python.org/3.7/
210-
.. _Python 3.8: https://docs.python.org/3.8/
211207
.. _Python 3.9: https://docs.python.org/3.9/
212208
.. _Python 3.10: https://docs.python.org/3.10/
213209
.. _Python 3.11: https://docs.python.org/3.11/

google/api_core/_python_package_support.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@
2525
_get_distribution_and_import_packages,
2626
)
2727

28-
if sys.version_info >= (3, 8):
29-
from importlib import metadata
30-
else:
31-
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
32-
# this code path once we drop support for Python 3.7
33-
import importlib_metadata as metadata
28+
from importlib import metadata
3429

3530
ParsedVersion = Tuple[int, ...]
3631

@@ -85,8 +80,7 @@ def get_dependency_version(
8580
"""Get the parsed version of an installed package dependency.
8681
8782
This function checks for an installed package and returns its version
88-
as a comparable tuple of integers object for safe comparison. It handles
89-
both modern (Python 3.8+) and legacy (Python 3.7) environments.
83+
as a comparable tuple of integers object for safe comparison.
9084
9185
Args:
9286
dependency_name: The distribution name of the package (e.g., 'requests').

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ dependencies = [
5050
"proto-plus >= 1.25.0, < 2.0.0; python_version >= '3.13'",
5151
"google-auth >= 2.14.1, < 3.0.0",
5252
"requests >= 2.18.0, < 3.0.0",
53-
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
54-
# `importlib_metadata` once we drop support for Python 3.7
55-
"importlib_metadata>=1.4; python_version<'3.8'",
5653
]
5754
dynamic = ["version"]
5855

scripts/readme-gen/templates/install_deps.tmpl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Install Dependencies
1212
.. _Python Development Environment Setup Guide:
1313
https://cloud.google.com/python/setup
1414

15-
#. Create a virtualenv. Samples are compatible with Python 3.7+.
15+
#. Create a virtualenv. Samples are compatible with Python 3.9+.
1616

1717
.. code-block:: bash
1818

tests/unit/test_python_package_support.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,9 @@
3131
@pytest.mark.parametrize("version_string_to_test", ["1.2.3", "1.2.3b1"])
3232
def test_get_dependency_version(mocker, version_string_to_test):
3333
"""Test get_dependency_version."""
34-
if sys.version_info >= (3, 8):
35-
mock_importlib = mocker.patch(
36-
"importlib.metadata.version", return_value=version_string_to_test
37-
)
38-
else:
39-
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
40-
# `importlib_metadata` once we drop support for Python 3.7
41-
mock_importlib = mocker.patch(
42-
"importlib_metadata.version", return_value=version_string_to_test
43-
)
34+
mock_importlib = mocker.patch(
35+
"importlib.metadata.version", return_value=version_string_to_test
36+
)
4437
expected = DependencyVersion(
4538
parse_version_to_tuple(version_string_to_test), version_string_to_test
4639
)

0 commit comments

Comments
 (0)