From af617f3360d5f080e8bc600bfa402380dcd798f6 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 10 Jan 2025 11:13:53 +0800 Subject: [PATCH 1/3] bump http-client-python 0.6.1 --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 5fef93348ee..8ca439ef30c 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "~0.6.0", + "@typespec/http-client-python": "~0.6.1", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 863407fd4a0..b4adcf458a2 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "~0.6.0", + "@typespec/http-client-python": "~0.6.1", "fs-extra": "~11.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16907db2b22..0df0c7dc81b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,8 +54,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: ~0.6.0 - version: 0.6.0(qlnncdzlvp4megu6e6j34u5d6q) + specifier: ~0.6.1 + version: 0.6.1(qlnncdzlvp4megu6e6j34u5d6q) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -76,8 +76,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: ~0.6.0 - version: 0.6.0(qlnncdzlvp4megu6e6j34u5d6q) + specifier: ~0.6.1 + version: 0.6.1(qlnncdzlvp4megu6e6j34u5d6q) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1202,8 +1202,8 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - '@typespec/http-client-python@0.6.0': - resolution: {integrity: sha512-BLvxs+p+w2lmzDrHz8mGQiH6Ko0BzogsDKbKLGG8AurK1cFb6nS/SOOeqOPx19GqdTynt9YfJNKD2rkNDoK9tQ==} + '@typespec/http-client-python@0.6.1': + resolution: {integrity: sha512-UrhN9uRS4C6A85tUJ/b3Q+KN1pZaLA8AIX3MbKHgrWfb91cgk6SjlBaAkpVIC3fVaMwXVjUZIsSSmVsHwkPUjg==} engines: {node: '>=18.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.49.0 <1.0.0' @@ -4868,7 +4868,7 @@ snapshots: yaml: 2.5.1 yargs: 17.7.2 - '@typespec/http-client-python@0.6.0(qlnncdzlvp4megu6e6j34u5d6q)': + '@typespec/http-client-python@0.6.1(qlnncdzlvp4megu6e6j34u5d6q)': dependencies: '@azure-tools/typespec-autorest': 0.49.0(nwofiqdfkiaeq4xrrk3jkqf6au) '@azure-tools/typespec-azure-core': 0.49.0(@typespec/compiler@0.63.0)(@typespec/http@0.63.0(@typespec/compiler@0.63.0))(@typespec/rest@0.63.0(@typespec/compiler@0.63.0)(@typespec/http@0.63.0(@typespec/compiler@0.63.0))) From b9687e7b5e6a90137efc3f89cb849a09789a5716 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 10 Jan 2025 11:16:02 +0800 Subject: [PATCH 2/3] changelog --- .../bump-http-client-python-0.6.1-2025-0-10-11-15-33.md | 8 ++++++++ .../bump-http-client-python-0.6.1-2025-0-10-11-15-50.md | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 .chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-33.md create mode 100644 .chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-50.md diff --git a/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-33.md b/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-33.md new file mode 100644 index 00000000000..b149b7f59bb --- /dev/null +++ b/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-33.md @@ -0,0 +1,8 @@ +--- +changeKind: fix +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Only add linting disables for a file with too many lines if the file doesn't already disable this linter rule \ No newline at end of file diff --git a/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-50.md b/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-50.md new file mode 100644 index 00000000000..c9a5e4d9e56 --- /dev/null +++ b/.chronus/changes/bump-http-client-python-0.6.1-2025-0-10-11-15-50.md @@ -0,0 +1,8 @@ +--- +changeKind: fix +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Generate __init__ for internal models to allow for discriminator needs \ No newline at end of file From 06ff3a084b438f0226a2579caa656e60e41cd186 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 10 Jan 2025 03:46:46 +0000 Subject: [PATCH 3/3] regenerate --- .../authentication/union/_client.py | 2 +- .../authentication/union/_configuration.py | 2 +- .../authentication/union/aio/_client.py | 2 +- .../union/aio/_configuration.py | 2 +- .../core/access/models/_models.py | 121 ++++++++++++++++++ .../authentication/union/_client.py | 2 +- .../authentication/union/_configuration.py | 2 +- .../authentication/union/aio/_client.py | 2 +- .../union/aio/_configuration.py | 2 +- 9 files changed, 129 insertions(+), 8 deletions(-) diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_client.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_client.py index a561a3c40ba..7881ff0baba 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_client.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_client.py @@ -27,7 +27,7 @@ class UnionClient(UnionClientOperationsMixin): # pylint: disable=client-accepts """Illustrates clients generated with ApiKey and OAuth2 authentication. :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + AzureKeyCredential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential :keyword endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_configuration.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_configuration.py index cf4839cdef1..cd3a346a1e8 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_configuration.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_configuration.py @@ -24,7 +24,7 @@ class UnionClientConfiguration: # pylint: disable=too-many-instance-attributes attributes. :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + AzureKeyCredential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential :param endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_client.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_client.py index 0a27dd13936..993bf51b15c 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_client.py @@ -27,7 +27,7 @@ class UnionClient(UnionClientOperationsMixin): # pylint: disable=client-accepts """Illustrates clients generated with ApiKey and OAuth2 authentication. :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + AzureKeyCredential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential :keyword endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_configuration.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_configuration.py index c9798c0298b..90a3855b9ed 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_configuration.py @@ -24,7 +24,7 @@ class UnionClientConfiguration: # pylint: disable=too-many-instance-attributes attributes. :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + AzureKeyCredential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential :param endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py index 99df79c9232..0506e0e6a3c 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py @@ -35,6 +35,24 @@ class AbstractModel(_model_base.Model): name: str = rest_field() """Required.""" + @overload + def __init__( + self, + *, + kind: str, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class BaseModel(_model_base.Model): """Used in internal operations, should be generated but not exported. @@ -47,6 +65,23 @@ class BaseModel(_model_base.Model): name: str = rest_field() """Required.""" + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class InnerModel(_model_base.Model): """Used in internal operations, should be generated but not exported. @@ -59,6 +94,23 @@ class InnerModel(_model_base.Model): name: str = rest_field() """Required.""" + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class InternalDecoratorModelInInternal(_model_base.Model): """Used in an internal operation, should be generated but not exported. @@ -71,6 +123,23 @@ class InternalDecoratorModelInInternal(_model_base.Model): name: str = rest_field() """Required.""" + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class NoDecoratorModelInInternal(_model_base.Model): """Used in an internal operation, should be generated but not exported. @@ -83,6 +152,23 @@ class NoDecoratorModelInInternal(_model_base.Model): name: str = rest_field() """Required.""" + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class NoDecoratorModelInPublic(_model_base.Model): """Used in a public operation, should be generated and exported. @@ -126,6 +212,24 @@ class OuterModel(BaseModel): inner: "_models._models.InnerModel" = rest_field() """Required.""" + @overload + def __init__( + self, + *, + name: str, + inner: "_models._models.InnerModel", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + class PublicDecoratorModelInInternal(_model_base.Model): """Used in an internal operation but with public decorator, should be generated and exported. @@ -198,6 +302,23 @@ class RealModel(AbstractModel, discriminator="real"): kind: Literal["real"] = rest_discriminator(name="kind") # type: ignore """Required. Default value is \"real\".""" + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, kind="real", **kwargs) + class SharedModel(_model_base.Model): """Used by both public and internal operation. It should be generated and exported. diff --git a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_client.py b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_client.py index abb07aae6bd..48340c55080 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_client.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_client.py @@ -26,7 +26,7 @@ class UnionClient(UnionClientOperationsMixin): # pylint: disable=client-accepts """Illustrates clients generated with ApiKey and OAuth2 authentication. :param credential: Credential used to authenticate requests to the service. Is either a - ServiceKeyCredential type or a TokenCredential type. Required. + ServiceKeyCredential type or a token credential type. Required. :type credential: ~corehttp.credentials.ServiceKeyCredential or ~corehttp.credentials.TokenCredential :keyword endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_configuration.py b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_configuration.py index bb22df22692..36e2940644d 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_configuration.py @@ -24,7 +24,7 @@ class UnionClientConfiguration: attributes. :param credential: Credential used to authenticate requests to the service. Is either a - ServiceKeyCredential type or a TokenCredential type. Required. + ServiceKeyCredential type or a token credential type. Required. :type credential: ~corehttp.credentials.ServiceKeyCredential or ~corehttp.credentials.TokenCredential :param endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_client.py b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_client.py index 45b207363d9..3a94d864a33 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_client.py @@ -26,7 +26,7 @@ class UnionClient(UnionClientOperationsMixin): # pylint: disable=client-accepts """Illustrates clients generated with ApiKey and OAuth2 authentication. :param credential: Credential used to authenticate requests to the service. Is either a - ServiceKeyCredential type or a TokenCredential type. Required. + ServiceKeyCredential type or a token credential type. Required. :type credential: ~corehttp.credentials.ServiceKeyCredential or ~corehttp.credentials.AsyncTokenCredential :keyword endpoint: Service host. Default value is "http://localhost:3000". diff --git a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_configuration.py b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_configuration.py index 7e27994dadc..44d2e3884ff 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/aio/_configuration.py @@ -24,7 +24,7 @@ class UnionClientConfiguration: attributes. :param credential: Credential used to authenticate requests to the service. Is either a - ServiceKeyCredential type or a TokenCredential type. Required. + ServiceKeyCredential type or a token credential type. Required. :type credential: ~corehttp.credentials.ServiceKeyCredential or ~corehttp.credentials.AsyncTokenCredential :param endpoint: Service host. Default value is "http://localhost:3000".