Skip to content

Commit

Permalink
fix, python: allow extending alias types (#4190)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Aug 2, 2024
1 parent 8dc36c4 commit 7ec3428
Show file tree
Hide file tree
Showing 53 changed files with 2,439 additions and 4 deletions.
4 changes: 4 additions & 0 deletions generators/python/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.3.3] - 2024-08-02

- Fix: The generator now allows you to extend aliased types (as long as they're objects).

## [3.3.2] - 2024-08-02

- Fix: regression in readme generation introduced in 3.3.1
Expand Down
2 changes: 1 addition & 1 deletion generators/python/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.2
3.3.3
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _build_timeout_snippets(self) -> List[str]:

client_instantiation = AST.ClassInstantiation(
class_=self._root_client.sync_client.class_reference,
args=[AST.Expression("..."), AST.Expression('timeout=20.0')],
args=[AST.Expression("..."), AST.Expression("timeout=20.0")],
)

def _client_writer(writer: AST.NodeWriter) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ def get_filepath_for_type_id(self, type_id: ir_types.TypeId, as_request: bool) -
def get_all_properties_including_extensions(self, type_name: ir_types.TypeId) -> List[ir_types.ObjectProperty]:
declaration = self.get_declaration_for_type_id(type_name)
shape = declaration.shape.get_as_union()
if shape.type != "object":

if shape.type == "alias":
resolved_type_union = shape.resolved_type.get_as_union()
if resolved_type_union.type != "named":
raise RuntimeError(
f"Cannot get properties because {declaration.name.name.original_name} is not an object, it's a {shape.type}"
)
else:
return self.get_all_properties_including_extensions(resolved_type_union.name.type_id)
elif shape.type != "object":
raise RuntimeError(
f"Cannot get properties because {declaration.name.name.original_name} is not an object, it's a {shape.type}"
)
Expand Down
63 changes: 63 additions & 0 deletions seed/python-sdk/alias-extends/.github/workflows/ci.yml

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

4 changes: 4 additions & 0 deletions seed/python-sdk/alias-extends/.gitignore

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

40 changes: 40 additions & 0 deletions seed/python-sdk/alias-extends/.mock/definition/__package__.yml

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

2 changes: 2 additions & 0 deletions seed/python-sdk/alias-extends/.mock/definition/api.yml

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

1 change: 1 addition & 0 deletions seed/python-sdk/alias-extends/.mock/fern.config.json

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

1 change: 1 addition & 0 deletions seed/python-sdk/alias-extends/.mock/generators.yml

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

136 changes: 136 additions & 0 deletions seed/python-sdk/alias-extends/README.md

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

57 changes: 57 additions & 0 deletions seed/python-sdk/alias-extends/pyproject.toml

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

Loading

0 comments on commit 7ec3428

Please sign in to comment.