Skip to content

Commit

Permalink
do not add api version validation decorator to overload function (#2634)
Browse files Browse the repository at this point in the history
* do not add api version validation decorator to overload function

* changelog
  • Loading branch information
tadelesh authored Jun 14, 2024
1 parent b6c5aaf commit 369124f
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .chronus/changes/add-usage-2024-5-11-16-39-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:
- "@azure-tools/typespec-python"
---

Remove unnecessary doc for model which is only used for output
Remove unnecessary doc for model which is only used for output
7 changes: 7 additions & 0 deletions .chronus/changes/added_overload-2024-5-14-15-43-45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@autorest/python"
---

do not add api version validation decorator to overload function
2 changes: 1 addition & 1 deletion .chronus/changes/deserialization-fix-2024-4-24-16-48-41.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:
- "@azure-tools/typespec-python"
---

Fix deserialization error for lro when return type has discriminator and succeed in initial response
Fix deserialization error for lro when return type has discriminator and succeed in initial response
2 changes: 1 addition & 1 deletion .chronus/changes/fix_models_only-2024-5-11-21-50-18.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
- "@autorest/python"
---

generate sdks without operations
generate sdks without operations
2 changes: 1 addition & 1 deletion .chronus/changes/switch_to_rest-2024-4-30-12-59-16.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
- "@autorest/python"
---

remove support for deprecated azure.core.pipeline.transport requests and responses
remove support for deprecated azure.core.pipeline.transport requests and responses
2 changes: 1 addition & 1 deletion .chronus/changes/typing-self-2024-5-6-13-0-58.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ packages:
- "@azure-tools/typespec-python"
---

Change return type of `__aenter__/__enter__` to `Self`
Change return type of `__aenter__/__enter__` to `Self`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"devDependencies": {
"@azure-tools/cadl-ranch": "~0.12.7",
"@actions/github": "6.0.0",
"@chronus/chronus": "^0.10.1",
"@chronus/chronus": "^0.10.2",
"@chronus/github": "^0.3.2",
"@typespec/prettier-plugin-typespec": "~0.55.0",
"autorest": "3.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def _get_json_response_template_to_status_codes(


def _api_version_validation(builder: OperationType) -> str:
if builder.is_overload:
return ""
retval: List[str] = []
if builder.added_on:
retval.append(f' method_added_on="{builder.added_on}",')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def __init__(self, *args, **kwargs) -> None:
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -98,10 +94,6 @@ async def v2_in_interface(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand All @@ -128,10 +120,6 @@ async def v2_in_interface(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -248,9 +236,6 @@ async def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], *
class AddedClientOperationsMixin(AddedClientMixinABC):

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: _models.ModelV1, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -288,9 +273,6 @@ async def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: JSON, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -320,9 +302,6 @@ async def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: IO[bytes], *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -445,10 +424,6 @@ async def v1(
return deserialized # type: ignore

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(
self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -482,10 +457,6 @@ async def v2(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand All @@ -510,10 +481,6 @@ async def v2(self, body: JSON, *, content_type: str = "application/json", **kwar
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ def __init__(self, *args, **kwargs):
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2_in_interface(
self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -149,10 +145,6 @@ def v2_in_interface(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2_in_interface(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2_in_interface.
Expand All @@ -177,10 +169,6 @@ def v2_in_interface(self, body: JSON, *, content_type: str = "application/json",
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2_in_interface(
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -297,9 +285,6 @@ def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwarg
class AddedClientOperationsMixin(AddedClientMixinABC):

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
def v1(
self, body: _models.ModelV1, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -337,9 +322,6 @@ def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
def v1(
self, body: JSON, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -369,9 +351,6 @@ def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
def v1(
self, body: IO[bytes], *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -492,10 +471,6 @@ def v1(self, body: Union[_models.ModelV1, JSON, IO[bytes]], *, header_v2: str, *
return deserialized # type: ignore

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2(self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand Down Expand Up @@ -527,10 +502,6 @@ def v2(self, body: _models.ModelV2, *, content_type: str = "application/json", *
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand All @@ -555,10 +526,6 @@ def v2(self, body: JSON, *, content_type: str = "application/json", **kwargs: An
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
def v2(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ def __init__(self, *args, **kwargs) -> None:
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -97,10 +93,6 @@ async def v2_in_interface(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand All @@ -127,10 +119,6 @@ async def v2_in_interface(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2_in_interface(
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -246,9 +234,6 @@ async def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], *
class AddedClientOperationsMixin(AddedClientMixinABC):

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: _models.ModelV1, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -286,9 +271,6 @@ async def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: JSON, *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -318,9 +300,6 @@ async def v1(
"""

@overload
@api_version_validation(
params_added_on={"v2": ["header_v2"]},
)
async def v1(
self, body: IO[bytes], *, header_v2: str, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV1:
Expand Down Expand Up @@ -442,10 +421,6 @@ async def v1(
return deserialized # type: ignore

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(
self, body: _models.ModelV2, *, content_type: str = "application/json", **kwargs: Any
) -> _models.ModelV2:
Expand Down Expand Up @@ -479,10 +454,6 @@ async def v2(
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand All @@ -507,10 +478,6 @@ async def v2(self, body: JSON, *, content_type: str = "application/json", **kwar
"""

@overload
@api_version_validation(
method_added_on="v2",
params_added_on={"v2": ["content_type", "accept"]},
)
async def v2(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.ModelV2:
"""v2.
Expand Down
Loading

0 comments on commit 369124f

Please sign in to comment.