-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async DefaultAzureCredential incompatible with AsyncTokenCredential per pyright #27704
Comments
I think it would be less disruptive to update AsyncTokenCredential (although I'm not sure if this would be considered breaking): async def close(self) -> None:
pass
async def __aenter__(self) -> typing.Self:
pass
async def __aexit__(self, *args: Any) -> None:
pass |
@mccoyp is this something you are working on? (I want to avoid dup the work) |
@xiangyan99 Looks like pyright is more strict than mypy, and in a similar boat as PyCharm's type checker. #25788 should resolve this. When I last spoke with Laurent, he feels that we should update our type signatures to correctly implement the TokenCredential protocols (even when some of the kwargs can't be used, like |
After taking a look at reference docs, I do think updating the protocol definition would be a better option since examples use async def __aexit__(self, *exc):
print('Finishing')
return False That said, I do think it would be a breaking change to put these named parameters into |
Resolved by #31494. |
Re-opening, needed to rollback the code that fixed this error. Details in #31585 |
With the changes in #31585, seems like the fix for this is to update the Like here. async def __aexit__(
self,
exc_type: Optional[Type[BaseException]] = None,
exc_value: Optional[BaseException] = None,
traceback: Optional[TracebackType] = None,
) -> None:
await self.close() |
Seems like https://github.com/Azure/azure-sdk-for-python/pull/31578/files can fix it. :) |
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
.The text was updated successfully, but these errors were encountered: