Skip to content

Commit

Permalink
[http-client-python] Update mypy and pyright (#5498)
Browse files Browse the repository at this point in the history
autorest.python PR: Azure/autorest.python#2989
  • Loading branch information
kristapratico authored Jan 7, 2025
1 parent 930ac13 commit aa4e698
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/http-client-python/generator/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-e ./generator
pyright==1.1.389
pyright==1.1.391
pylint==3.2.7
tox==4.16.0
mypy==1.13.0
mypy==1.14.1
colorama==0.4.6
debugpy==1.8.2
pytest==8.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Union,
TYPE_CHECKING,
cast,
Sequence,
)
from abc import abstractmethod

Expand All @@ -39,7 +40,7 @@
from .request_builder import RequestBuilder


OverloadListType = TypeVar("OverloadListType", bound=Union[List["Operation"], List["RequestBuilder"]])
OverloadListType = TypeVar("OverloadListType", bound=Union[Sequence["Operation"], Sequence["RequestBuilder"]])

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Generic,
TypeVar,
cast,
Sequence,
)

from .request_builder_parameter import RequestBuilderParameter
Expand Down Expand Up @@ -54,7 +55,7 @@ def is_internal(target: Optional[BaseType]) -> bool:


class OperationBase( # pylint: disable=too-many-public-methods,too-many-instance-attributes
Generic[ResponseType], BaseBuilder[ParameterList, List["Operation"]]
Generic[ResponseType], BaseBuilder[ParameterList, Sequence["Operation"]]
):
def __init__(
self,
Expand All @@ -67,7 +68,7 @@ def __init__(
responses: List[ResponseType],
exceptions: List[Response],
*,
overloads: Optional[List["Operation"]] = None,
overloads: Optional[Sequence["Operation"]] = None,
) -> None:
super().__init__(
code_model=code_model,
Expand All @@ -77,7 +78,7 @@ def __init__(
parameters=parameters,
overloads=overloads,
)
self.overloads: List["Operation"] = overloads or []
self.overloads: Sequence["Operation"] = overloads or []
self.responses = responses
self.request_builder = request_builder
self.deprecated = False
Expand Down Expand Up @@ -465,7 +466,9 @@ def from_yaml(
responses = [cast(ResponseType, get_response(r, code_model)) for r in yaml_data["responses"]]
exceptions = [Response.from_yaml(e, code_model) for e in yaml_data["exceptions"]]
parameter_list = ParameterList.from_yaml(yaml_data, code_model)
overloads = [cls.from_yaml(overload, code_model, client) for overload in yaml_data.get("overloads", [])]
overloads = [
cast(Operation, cls.from_yaml(overload, code_model, client)) for overload in yaml_data.get("overloads", [])
]

return cls(
yaml_data=yaml_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
Any,
Callable,
Dict,
List,
TypeVar,
TYPE_CHECKING,
Union,
Optional,
Sequence,
cast,
)
from abc import abstractmethod

Expand All @@ -34,7 +35,7 @@
)


class RequestBuilderBase(BaseBuilder[ParameterListType, List["RequestBuilder"]]):
class RequestBuilderBase(BaseBuilder[ParameterListType, Sequence["RequestBuilder"]]):
def __init__(
self,
yaml_data: Dict[str, Any],
Expand All @@ -43,7 +44,7 @@ def __init__(
name: str,
parameters: ParameterListType,
*,
overloads: Optional[List["RequestBuilder"]] = None,
overloads: Optional[Sequence["RequestBuilder"]] = None,
) -> None:
super().__init__(
code_model=code_model,
Expand All @@ -53,7 +54,7 @@ def __init__(
parameters=parameters,
overloads=overloads,
)
self.overloads: List["RequestBuilder"] = overloads or []
self.overloads: Sequence["RequestBuilder"] = overloads or []
self.url: str = yaml_data["url"]
self.method: str = yaml_data["method"]
self.want_tracing = False
Expand Down Expand Up @@ -154,7 +155,7 @@ def from_yaml(
# So add operation group name is effective method

overloads = [
RequestBuilder.from_yaml(rb_yaml_data, code_model, client)
cast(RequestBuilder, RequestBuilder.from_yaml(rb_yaml_data, code_model, client))
for rb_yaml_data in yaml_data.get("overloads", [])
]
parameter_list = cls.parameter_list_type()(yaml_data, code_model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pytest
pytest-asyncio==0.14.0;python_full_version>="3.5.2"
azure-core==1.30.0
azure-mgmt-core==1.3.2
pyright==1.1.389
pyright==1.1.391
pylint==3.2.7
tox==4.18.1
mypy==1.13.0
mypy==1.14.1

# only for azure
-e ./generated/azure-client-generator-core-access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ aiohttp;python_full_version>="3.5.2"
requests==2.32.2
pytest
pytest-asyncio==0.14.0;python_full_version>="3.5.2"
pyright==1.1.389
pyright==1.1.391
pylint==3.2.7
tox==4.18.1
mypy==1.13.0
mypy==1.14.1


# common test case
Expand Down

0 comments on commit aa4e698

Please sign in to comment.