Skip to content

Conversation

@rakshith91
Copy link
Contributor

Duplicate of #5266

Resolves #5022

@rakshith91 rakshith91 requested a review from lmazuel as a code owner May 24, 2019 01:22
@adxsdk6
Copy link

adxsdk6 commented May 24, 2019

Can one of the admins verify this patch?

@rakshith91 rakshith91 requested a review from bryevdv May 24, 2019 17:40
@rakshith91 rakshith91 self-assigned this May 24, 2019
# --------------------------------------------------------------------------
from typing import List, Union, Optional, TypeVar, Callable
from azure.core.pipeline.policies import AsyncHTTPPolicy, SansIOHTTPPolicy
from azure.core.exceptions import (
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sender any?

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

@xiangyan99 xiangyan99 May 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. transport is one kind of transport type, not any
  2. Shouldn't List[Union[HTTPPolicy, SansIOHTTPPolicy] be PoliciesType?

Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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")
Copy link
Member

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

Copy link
Member

@xiangyan99 xiangyan99 May 24, 2019

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")
Copy link
Member

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]:
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PipelineRequestType?

@rakshith91 rakshith91 merged commit 76e055c into Azure:master May 25, 2019
@rakshith91 rakshith91 deleted the mypy-core branch May 25, 2019 01:44
azure-sdk added a commit that referenced this pull request Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[azure-core]Need successful MyPy pass

3 participants