Pyright reports a type error when the async DefaultAzureCredential is used anywhere where an AsyncTokenCredential is expected:
C:\Users\krpratic\azure-sdk-for-python\sdk\cognitivelanguage\azure-ai-language-conversations\samples\async\sample_authentication_async.py:57:66 - error: Argument of type "DefaultAzureCredential" cannot be assigned to parameter "credential" of type "AzureKeyCredential | AsyncTokenCredential" in function "__init__"
Type "DefaultAzureCredential" cannot be assigned to type "AzureKeyCredential | AsyncTokenCredential"
"DefaultAzureCredential" is incompatible with "AzureKeyCredential"
"DefaultAzureCredential" is incompatible with protocol "AsyncTokenCredential"
"__aenter__" is an incompatible type
Type "() -> Coroutine[Any, Any, DefaultAzureCredential]" cannot be assigned to type "() -> Coroutine[Any, Any, None]"
Function return type "Coroutine[Any, Any, DefaultAzureCredential]" is incompatible with type "Coroutine[Any, Any, None]"
"__aexit__" is an incompatible type
Type "(*args: Unknown) -> Coroutine[Any, Any, None]" cannot be assigned to type "(exc_type: Unknown, exc_value: Unknown, traceback: Unknown) -> Coroutine[Any, Any, None]"
This is due to the difference in how the Protocol is typed vs. how it is typed in identity:
Pyright reports a type error when the async DefaultAzureCredential is used anywhere where an AsyncTokenCredential is expected:
This is due to the difference in how the Protocol is typed vs. how it is typed in identity:
azure-sdk-for-python/sdk/core/azure-core/azure/core/credentials_async.py
Lines 28 to 35 in ac0672f
azure-sdk-for-python/sdk/identity/azure-identity/azure/identity/aio/_internal/__init__.py
Lines 11 to 20 in ac0672f
Note that this doesn't occur with the sync credential since
__enter__and__exit__are not described byTokenCredential.