pulumi/pkg/codegen
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
..
docs [codegen/docs] Fix the generation of Function names, args, and result type names (#4490) 2020-04-27 17:47:01 -07:00
dotnet [codegen/docs] Fix the generation of Function names, args, and result type names (#4490) 2020-04-27 17:47:01 -07:00
go [codegen/docs] Fix the generation of Function names, args, and result type names (#4490) 2020-04-27 17:47:01 -07:00
hcl2 [codegen/python] Fix nested quotes. (#4539) 2020-04-30 16:34:25 -07:00
internal/test [codegen/python] Fix nested quotes. (#4539) 2020-04-30 16:34:25 -07:00
nodejs [codegen] Add support for caching package schemas. (#4534) 2020-04-30 13:22:24 -07:00
python [codegen/python] Fix nested quotes. (#4539) 2020-04-30 16:34:25 -07:00
schema C# name resolution (#4468) 2020-04-23 00:42:31 +02:00
docs.go [codegen/docs] Fix the generation of Function names, args, and result type names (#4490) 2020-04-27 17:47:01 -07:00
docs_test.go Remove non-relevant examples and empty examples section from docs comments (#4184) 2020-03-26 10:30:04 -07:00
utilities.go [codegen/python] Fix nested quotes. (#4539) 2020-04-30 16:34:25 -07:00