Skip to content

Commit

Permalink
fix: add legacy imports to preserve backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vchudnov-g committed Jan 26, 2024
1 parent ffe7555 commit 5bcd7a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
24 changes: 12 additions & 12 deletions google/api_core/retry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
# The following imports are for backwards compatibility with https://github.com/googleapis/python-api-core/blob/4d7d2edee2c108d43deb151e6e0fdceb56b73275/google/api_core/retry.py
#
# TODO: Revert these imports on the next major version release (https://github.com/googleapis/python-api-core/issues/576)
import datetime
import functools
import logging
import random
import sys
import time
import inspect
import warnings
from typing import Any, Callable, TypeVar, TYPE_CHECKING
from google.api_core import datetime_helpers
from google.api_core import exceptions
from google.auth import exceptions as auth_exceptions
import datetime # noqa: F401
import functools # noqa: F401
import logging # noqa: F401
import random # noqa: F401
import sys # noqa: F401
import time # noqa: F401
import inspect # noqa: F401
import warnings # noqa: F401
from typing import Any, Callable, TypeVar, TYPE_CHECKING # noqa: F401
from google.api_core import datetime_helpers # noqa: F401
from google.api_core import exceptions # noqa: F401
from google.auth import exceptions as auth_exceptions # noqa: F401

__all__ = (
"exponential_sleep_generator",
Expand Down
30 changes: 14 additions & 16 deletions tests/unit/retry/test_retry_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

def test_legacy_imports_retry_unary_sync():
# TODO: Delete this test when when we revert these imports on the
# next major version release
# (https://github.com/googleapis/python-api-core/issues/576)

from google.api_core.retry import logging
from google.api_core.retry import datetime
from google.api_core.retry import functools
from google.api_core.retry import logging
from google.api_core.retry import random
from google.api_core.retry import sys
from google.api_core.retry import time
from google.api_core.retry import inspect
from google.api_core.retry import warnings
from google.api_core.retry import Any, Callable, TypeVar, TYPE_CHECKING

from google.api_core.retry import datetime_helpers
from google.api_core.retry import exceptions
from google.api_core.retry import auth_exceptions
from google.api_core.retry import datetime # noqa: F401
from google.api_core.retry import functools # noqa: F401
from google.api_core.retry import logging # noqa: F401
from google.api_core.retry import random # noqa: F401
from google.api_core.retry import sys # noqa: F401
from google.api_core.retry import time # noqa: F401
from google.api_core.retry import inspect # noqa: F401
from google.api_core.retry import warnings # noqa: F401
from google.api_core.retry import Any, Callable, TypeVar, TYPE_CHECKING # noqa: F401

from google.api_core.retry import datetime_helpers # noqa: F401
from google.api_core.retry import exceptions # noqa: F401
from google.api_core.retry import auth_exceptions # noqa: F401

### FIXME: How do we test the following, and how do we import it in __init__.py?
# import google.api_core.retry.requests.exceptions
Expand All @@ -43,7 +41,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
from google.api_core import retry_async # noqa: F401

### FIXME: each of the following cause errors on the "retry_async" part: module not found
# import google.api_core.retry_async.functools
Expand Down

0 comments on commit 5bcd7a3

Please sign in to comment.