pulumi/pkg/codegen/hcl2/model
Pat Gavlin 1d6cce98fe
[codegen/python] Fix nested quotes. (#4539)
Unlike most languages with interpolated strings, Python's formatted
string literals do not allow the nesting of quotes. For example,
this expression is not legal Python:

    f"Foo {"bar"} baz"

If an interpolation requires quotes, those quotes nust differ from the
quotes used by the enclosing literal. We can fix the previous example
by rewriting it with single quotes:

    f"Foo {'bar'} baz"

However, this presents a problem if there are more than two levels of
nesting, as Python only has two kinds of quotes (four if the outermost
string uses """ or '''): in this case, the expression becomes
unspellable, and must be assigned to a local that is then used in place
of the original expression. So this:

    f"Foo {bar[f'index {baz["qux"]}']} zed"

becomes this:

    index = "qux"
    f"Foo {bar[f'index {baz[index]}']}"

To put it bluntly, Python code generation reqiures register allocation,
but for quotes. These changes implement exactly that.

These changes also include a fix for traversals that access values that
are dictionaries rather than objects, and must use indexers rather than
attributes.
2020-04-30 16:34:25 -07:00
..
format Codegen: collect imports from function calls. (#4445) 2020-04-21 10:24:42 -07:00
attribute.go HCL2: support for tolerating missing variables. (#4430) 2020-04-17 08:24:44 -07:00
binder_expression.go [codegen/hcl2] Separate binding and typechecking. (#4483) 2020-04-24 08:52:52 -07:00
binder_expression_test.go Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
block.go HCL2: support for tolerating missing variables. (#4430) 2020-04-17 08:24:44 -07:00
body.go HCL2: support for tolerating missing variables. (#4430) 2020-04-17 08:24:44 -07:00
diagnostics.go [codegen/hcl2] Separate binding and typechecking. (#4483) 2020-04-24 08:52:52 -07:00
expression.go [codegen/python] Fix nested quotes. (#4539) 2020-04-30 16:34:25 -07:00
functions.go Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
printer.go [codegen/hcl] Fix binop printing. (#4537) 2020-04-30 13:44:05 -07:00
scope.go Various codegen updates. (#4424) 2020-04-16 16:44:34 -07:00
spec.md Add an HCL2 static typechecker and semantic model. (#4087) 2020-03-18 09:28:57 -07:00
traversable.go [codegen/hcl2] Separate binding and typechecking. (#4483) 2020-04-24 08:52:52 -07:00
type.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_collection.go HCL2 updates (#4309) 2020-04-06 19:43:16 -07:00
type_eventuals.go [hcl2/model] Propagate annotations in InputType. (#4535) 2020-04-30 14:16:43 -07:00
type_list.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_map.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_none.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_object.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_opaque.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_output.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_promise.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_scope.go Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
type_set.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_test.go Add an HCL2 static typechecker and semantic model. (#4087) 2020-03-18 09:28:57 -07:00
type_tuple.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
type_union.go Fix output property names in Python codegen. 2020-04-21 10:25:27 -07:00
utilities.go Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
visitor.go Fix Python input property names. 2020-04-21 13:55:33 -07:00