Skip to content

Commit

Permalink
fix(pacmak): use builtins.str instead of str for type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Dec 1, 2022
1 parent 0b7dcc8 commit fd06e86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/lib/targets/python/type-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class UserType implements TypeName {
const wrapType =
typeAnnotation && parameterType && isStruct
? (pyType: string) =>
`typing.Union[${pyType}, typing.Dict[str, typing.Any]]`
`typing.Union[${pyType}, typing.Dict[builtins.str, typing.Any]]`
: (pyType: string) => pyType;

// Emit aliased imports for dependencies (this avoids name collisions)
Expand Down
4 changes: 2 additions & 2 deletions packages/jsii-pacmak/test/targets/python/type-name.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ describe(toTypeName, () => {
{
name: 'Struct parameter type annotation',
input: { fqn: `${assembly.name}.Struct` },
forwardPythonType: `typing.Union["Struct", typing.Dict[str, typing.Any]]`,
pythonType: `typing.Union[Struct, typing.Dict[str, typing.Any]]`,
forwardPythonType: `typing.Union["Struct", typing.Dict[builtins.str, typing.Any]]`,
pythonType: `typing.Union[Struct, typing.Dict[builtins.str, typing.Any]]`,
context: {
typeAnnotation: true,
parameterType: true,
Expand Down

0 comments on commit fd06e86

Please sign in to comment.