Skip to content

Commit 388efaa

Browse files
authored
[Core] Add runtime_checkable to protocol definitions (#25187)
1 parent 4fd2595 commit 388efaa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

sdk/core/azure-core/azure/core/credentials.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# -------------------------------------------------------------------------
66
from collections import namedtuple
77
from typing import Any, NamedTuple, Optional
8-
from typing_extensions import Protocol
8+
from typing_extensions import Protocol, runtime_checkable
99
import six
1010

1111

@@ -19,6 +19,7 @@ class AccessToken(NamedTuple):
1919
AccessToken.expires_on.__doc__ = """The token's expiration time in Unix time."""
2020

2121

22+
@runtime_checkable
2223
class TokenCredential(Protocol):
2324
"""Protocol for classes able to provide OAuth tokens."""
2425

sdk/core/azure-core/azure/core/credentials_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# Licensed under the MIT License.
44
# ------------------------------------
55
from typing import Any, Optional
6-
from typing_extensions import Protocol
6+
from typing_extensions import Protocol, runtime_checkable
77
from .credentials import AccessToken as _AccessToken
88

9+
@runtime_checkable
910
class AsyncTokenCredential(Protocol):
1011
"""Protocol for classes able to provide OAuth tokens."""
1112

0 commit comments

Comments
 (0)