-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
bugSomething isn't workingSomething isn't workingfixed-in-8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0transformationThe issue is related to logic of transforming Lark AST into Python data structureThe issue is related to logic of transforming Lark AST into Python data structure
Description
Describe the bug
I'm using this great library to parse a terraform script, manipulate it and write it back to a .tf file.
I've noticed that parsing a string and reconstructing it does not return the original value, when we have a variable block of type object.
Software:
- OS: macOS
- Python version 3.13.1
- python-hcl2 version 7.2.0
Snippet of HCL2 code causing the unexpected behaviour:
import hcl2
original_string = """
variable "object" {
type = object({
key = string
value = string
})
}
"""
parsed_hcl = hcl2.loads(original_string, with_meta=True)
ast = hcl2.reverse_transform(parsed_hcl)
reconstructed_string = hcl2.writes(ast)
print(reconstructed_string)
# Prints:
# variable "object" {
# type = object({"key":"string","value":"string"})
# }Expected behavior
One would expect to get back the original value:
variable "object" {
type = object({
key = string
value = string
})
}
Exception traceback (if applicable):
N/a
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixed-in-8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0transformationThe issue is related to logic of transforming Lark AST into Python data structureThe issue is related to logic of transforming Lark AST into Python data structure