Skip to content

Commit 6493118

Browse files
fix: Log version check errors (#858)
* Use error log over `print` to avoid stdout write * Move common return to end of function * Update google/api_core/_python_version_support.py Co-authored-by: Chalmer Lowe <chalmerlowe@google.com> * Fix lint error --------- Co-authored-by: Chalmer Lowe <chalmerlowe@google.com>
1 parent c97b3a0 commit 6493118

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

google/api_core/_python_version_support.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616

1717
import datetime
1818
import enum
19+
import logging
1920
import warnings
2021
import sys
2122
import textwrap
2223
from typing import Any, List, NamedTuple, Optional, Dict, Tuple
2324

2425

26+
_LOGGER = logging.getLogger(__name__)
27+
28+
2529
class PythonVersionStatus(enum.Enum):
2630
"""Support status of a Python version in this client library artifact release.
2731
@@ -168,11 +172,14 @@ def _get_pypi_package_name(module_name):
168172
if module_name in module_to_distributions: # pragma: NO COVER
169173
# The value is a list of distribution names, take the first one
170174
return module_to_distributions[module_name][0]
171-
else:
172-
return None # Module not found in the mapping
173175
except Exception as e:
174-
print(f"An error occurred: {e}")
175-
return None
176+
_LOGGER.info(
177+
"An error occurred while determining PyPI package name for %s: %s",
178+
module_name,
179+
e,
180+
)
181+
182+
return None
176183

177184

178185
def _get_distribution_and_import_packages(import_package: str) -> Tuple[str, Any]:

0 commit comments

Comments
 (0)