Skip to content

Commit

Permalink
fix: fix broken import for google.api_core.retry_async.AsyncRetry (#587)
Browse files Browse the repository at this point in the history
* fix: fix broken import for AsyncRetry

* fix import for AsyncRetry

* Resolve duplicate object description of google.api_core.retry.retry_unary_async.AsyncRetry

* move to google/api_core/retry_async.py
  • Loading branch information
parthea authored Jan 30, 2024
1 parent 7ffa182 commit ac012c0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/retry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Retry in AsyncIO

.. automodule:: google.api_core.retry_async
:members:
:noindex:
:show-inheritance:
3 changes: 0 additions & 3 deletions google/api_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@
from google.api_core import version as api_core_version

__version__ = api_core_version.__version__

# for backwards compatibility, expose async unary retries as google.api_core.retry_async
from .retry import retry_unary_async as retry_async # noqa: F401
34 changes: 34 additions & 0 deletions google/api_core/retry_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 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
#
# http://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.
#
# The following imports are for backwards compatibility with https://github.com/googleapis/python-api-core/blob/4d7d2edee2c108d43deb151e6e0fdceb56b73275/google/api_core/retry_async.py
#
# TODO: Revert these imports on the next major version release (https://github.com/googleapis/python-api-core/issues/576)
from google.api_core import datetime_helpers # noqa: F401
from google.api_core import exceptions # noqa: F401
from google.api_core.retry import exponential_sleep_generator # noqa: F401
from google.api_core.retry import if_exception_type # noqa: F401
from google.api_core.retry import if_transient_error # noqa: F401
from google.api_core.retry.retry_unary_async import AsyncRetry
from google.api_core.retry.retry_unary_async import retry_target

__all__ = (
"AsyncRetry",
"datetime_helpers",
"exceptions",
"exponential_sleep_generator",
"if_exception_type",
"if_transient_error",
"retry_target",
)
4 changes: 4 additions & 0 deletions tests/unit/retry/test_retry_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ def test_legacy_imports_retry_unary_async():
# next major version release
# (https://github.com/googleapis/python-api-core/issues/576)
from google.api_core import retry_async # noqa: F401

# See https://github.com/googleapis/python-api-core/issues/586
# for context on why we need to test this import this explicitly.
from google.api_core.retry_async import AsyncRetry # noqa: F401

0 comments on commit ac012c0

Please sign in to comment.