Skip to content
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

AsyncHTTPPolicy's next attribute is Optional[Any] #5797

Closed
chlowell opened this issue Jun 11, 2019 · 4 comments
Closed

AsyncHTTPPolicy's next attribute is Optional[Any] #5797

chlowell opened this issue Jun 11, 2019 · 4 comments
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.

Comments

@chlowell
Copy link
Member

Looks like this should be Optional[AsyncHTTPPolicy] instead; would next ever be anything else?

@chlowell chlowell added Azure.Core Client This issue points to a problem in the data-plane of the library. labels Jun 11, 2019
@xiangyan99
Copy link
Member

It should call transport as next. Close it. Will re-open if we see real requests.

@chlowell
Copy link
Member Author

Reopening this for further consideration because it creates mypy errors in subclasses. For example, line 94 of this code gets "Item "None" of "Optional[Any]" has no attribute "send"":

class ArcChallengeAuthPolicy(AsyncHTTPPolicy):
"""Policy for handling Azure Arc's challenge authentication"""
async def send(self, request: "PipelineRequest") -> "AsyncHttpResponse":
request.http_request.headers["Metadata"] = "true"
response = await self.next.send(request)

This can of course be worked around in the subclass but it would be better for AsyncHTTPPolicy to have the correct type.
Similar to HTTPPolicy, I think that type would be Union[AsyncHTTPPolicy, AsyncHttpTransport], which aligns with actual usage and the class's documentation. However, fixing this is more complicated than just changing the type because AsyncRedirectPolicy and AsyncRetryPolicy transitively inherit HTTPPolicy.

@chlowell chlowell reopened this Dec 16, 2020
@xiangyan99 xiangyan99 self-assigned this Dec 16, 2020
chlowell added a commit to chlowell/azure-sdk-for-python that referenced this issue Dec 16, 2020
chlowell added a commit to chlowell/azure-sdk-for-python that referenced this issue Dec 16, 2020
@xiangyan99 xiangyan99 mentioned this issue Jan 6, 2021
@xiangyan99
Copy link
Member

@chlowell We refactored HttpPolicy & AsyncHttpPolicy in #15831. Now AsyncHTTPPolicy is not a sub-class of HTTPPolicy any longer. Could you help to check if this issue is fixed?

@chlowell
Copy link
Member Author

Yes, that worked for my case.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

2 participants