-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Get successful mypy pass on azure core #5466
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
Conversation
|
Can one of the admins verify this patch? |
| # -------------------------------------------------------------------------- | ||
| from typing import List, Union, Optional, TypeVar, Callable | ||
| from azure.core.pipeline.policies import AsyncHTTPPolicy, SansIOHTTPPolicy | ||
| from azure.core.exceptions import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need "try" for AsyncHTTPPolicy?
|
|
||
| def __init__(self, sender): | ||
| # type: (HttpTransport) -> None | ||
| # type: (Any) -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is sender any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had HTTPSender in msrest which we don't have anymore. Can't find a relevant sender class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think HttpTransport is correct
|
|
||
| def __init__(self, transport, policies=None): | ||
| # type: (HttpTransport, List[Union[HTTPPolicy, SansIOHTTPPolicy]]) -> None | ||
| # type: (Any, List[Union[HTTPPolicy, SansIOHTTPPolicy]]) -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- transport is one kind of transport type, not any
- Shouldn't List[Union[HTTPPolicy, SansIOHTTPPolicy] be PoliciesType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
included this
| @classmethod | ||
| def deserialize_from_text(cls, response, content_type=None): | ||
| # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any | ||
| # type: (Optional[PipelineResponse], Optional[str]) -> Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we missed cls and response is not optional
| @classmethod | ||
| def deserialize_from_http_generics(cls, response): | ||
| # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any | ||
| # type: (PipelineResponse) -> Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, cls?
|
|
||
| def __init__(self, configuration=None, session=None, session_owner=True): | ||
| # type: (Optional[requests.Session]) -> None | ||
| # type: (Optional[Any], Optional[requests.Session], Any) -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
session_owner is bool
| from msrest.serialization import Model # type: ignore # pylint: disable=unused-import | ||
|
|
||
| AsyncHTTPResponseType = TypeVar("AsyncHTTPResponseType") | ||
| HTTPRequestType = TypeVar("HTTPRequestType") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTPRequestType is already defined in sdk/core/azure-core/azure/core/pipeline/init.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And seems like the only one uses AsyncHTTPResponseType & ImplPoliciesType is base_async.py
| from azure.core.pipeline.policies import AsyncHTTPPolicy, SansIOHTTPPolicy | ||
| from azure.core.common import ImplPoliciesType, PoliciesType | ||
|
|
||
| AsyncHTTPResponseType = TypeVar("AsyncHTTPResponseType") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AsyncHTTPResponseType is already defined in azure.core.common
| return request.data | ||
|
|
||
| async def send(self, request: HttpRequest, **config: Any) -> AsyncHttpResponse: | ||
| async def send(self, request: HttpRequest, **config: Any) -> Optional[Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not AsyncHttpResponse?
| # might provide our own implementation | ||
| from requests.structures import CaseInsensitiveDict | ||
| from azure.core.pipeline import ABC, AbstractContextManager | ||
| from azure.core.pipeline import ABC, AbstractContextManager, PipelineRequest, PipelineResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use PipelineRequestType instead of import?
Can this change pass PyLint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it does.
|
|
||
| def __init__(self, configuration=None, session=None, session_owner=True): | ||
| # type: (Optional[requests.Session]) -> None | ||
| # type: (Optional[Any], Optional[requests.Session], bool) -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is configuration type, not any
| Tuple, Callable, Iterator) | ||
|
|
||
| from azure.core.pipeline import ABC | ||
| from azure.core.pipeline import ABC, PipelineRequest, PipelineResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use PipelineRequestType
|
|
||
| def __init__(self, http_request, http_response=None, error=None, context=None): | ||
| # type: (PipelineRequest[HTTPRequestType], Exception, Optional[Dict[str, Any]]) -> None | ||
| # type: (PipelineRequest, PipelineResponse, Exception, Optional[Dict[str, Any]]) -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional[PipelineResponse]
| """ | ||
| This module is the requests implementation of Pipeline ABC | ||
| """ | ||
| from azure.core.pipeline import PipelineRequest, PipelineResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PipelineRequestType?
…5456 (#28923) Co-authored-by: Mike Harder <[email protected]>
Duplicate of #5266
Resolves #5022