Skip to content

Commit 628003e

Browse files
authored
fix: remove call to importlib.metadata.packages_distributions() for py38/py39 (#859)
* fix: remove call to importlib.metadata.packages_distributions() for py38/py39 * cover * update comment
1 parent 6493118 commit 628003e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

google/api_core/_python_version_support.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ def _flatten_message(text: str) -> str:
151151
return " ".join(textwrap.dedent(text).strip().split())
152152

153153

154-
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove once we
155-
# no longer support Python 3.7
156-
if sys.version_info < (3, 8):
154+
# TODO(https://github.com/googleapis/python-api-core/issues/835):
155+
# Remove once we no longer support Python 3.9.
156+
# `importlib.metadata.packages_distributions()` is only supported in Python 3.10 and newer
157+
# https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.packages_distributions
158+
if sys.version_info < (3, 10):
157159

158160
def _get_pypi_package_name(module_name): # pragma: NO COVER
159161
"""Determine the PyPI package name for a given module name."""
@@ -172,7 +174,7 @@ def _get_pypi_package_name(module_name):
172174
if module_name in module_to_distributions: # pragma: NO COVER
173175
# The value is a list of distribution names, take the first one
174176
return module_to_distributions[module_name][0]
175-
except Exception as e:
177+
except Exception as e: # pragma: NO COVER
176178
_LOGGER.info(
177179
"An error occurred while determining PyPI package name for %s: %s",
178180
module_name,

0 commit comments

Comments
 (0)