Skip to content

Commit 6d11b61

Browse files
committed
make SupportsGetToken type hint a forward reference
1 parent 55ca0f1 commit 6d11b61

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

sdk/keyvault/azure-security-keyvault/azure/security/keyvault/aio/_internal.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
# Licensed under the MIT License. See LICENSE.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
from typing import Any, Callable, Mapping, Optional
6+
from typing import Any, Callable, Mapping, Optional, TYPE_CHECKING
7+
if TYPE_CHECKING:
8+
try:
9+
from azure.core.credentials import SupportsGetToken
10+
except ImportError:
11+
# SupportsGetToken is a typing_extensions.Protocol; we don't depend on that package
12+
pass
713

8-
from azure.core.credentials import SupportsGetToken
914
from azure.core.async_paging import AsyncPagedMixin
1015
from azure.core.configuration import Configuration
1116
from azure.core.pipeline import AsyncPipeline
@@ -47,7 +52,7 @@ class _AsyncKeyVaultClientBase:
4752

4853
@staticmethod
4954
def create_config(
50-
credential: SupportsGetToken, api_version: str = None, **kwargs: Mapping[str, Any]
55+
credential: "SupportsGetToken", api_version: str = None, **kwargs: Mapping[str, Any]
5156
) -> Configuration:
5257
if api_version is None:
5358
api_version = KeyVaultClient.DEFAULT_API_VERSION
@@ -58,7 +63,7 @@ def create_config(
5863
def __init__(
5964
self,
6065
vault_url: str,
61-
credential: SupportsGetToken,
66+
credential: "SupportsGetToken",
6267
config: Configuration = None,
6368
transport: HttpTransport = None,
6469
api_version: str = None,

sdk/keyvault/azure-security-keyvault/azure/security/keyvault/aio/vault_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
# Licensed under the MIT License. See LICENSE.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
from typing import Any, Optional
6+
from typing import Any, Optional, TYPE_CHECKING
7+
if TYPE_CHECKING:
8+
try:
9+
from azure.core.credentials import SupportsGetToken
10+
except ImportError:
11+
# SupportsGetToken is a typing_extensions.Protocol; we don't depend on that package
12+
pass
713

814
from azure.core import Configuration
9-
from azure.core.credentials import SupportsGetToken
1015
from azure.core.pipeline.transport import HttpTransport
1116

1217
from ._internal import _AsyncKeyVaultClientBase
@@ -18,7 +23,7 @@ class VaultClient(_AsyncKeyVaultClientBase):
1823
def __init__(
1924
self,
2025
vault_url: str,
21-
credential: SupportsGetToken,
26+
credential: "SupportsGetToken",
2227
config: Configuration = None,
2328
transport: HttpTransport = None,
2429
api_version: str = None,

0 commit comments

Comments
 (0)