Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Generate __init__ for internal models to allow for discriminator needs
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading