python-hcl2 7.2.0__tar.gz → 7.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/CHANGELOG.md +8 -1
  2. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/PKG-INFO +1 -1
  3. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/hcl2.lark +1 -1
  4. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/reconstructor.py +14 -4
  5. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/transformer.py +5 -3
  6. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/version.py +2 -2
  7. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/PKG-INFO +1 -1
  8. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.codacy.yml +0 -0
  9. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.coveragerc +0 -0
  10. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.github/CODEOWNERS +0 -0
  11. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.github/ISSUE_TEMPLATE/hcl2-parsing-error.md +0 -0
  12. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.github/workflows/codeql-analysis.yml +0 -0
  13. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.github/workflows/pr_check.yml +0 -0
  14. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.github/workflows/publish.yml +0 -0
  15. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.gitignore +0 -0
  16. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.pre-commit-config.yaml +0 -0
  17. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/.yamllint.yml +0 -0
  18. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/LICENSE +0 -0
  19. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/MANIFEST.in +0 -0
  20. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/README.md +0 -0
  21. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/bin/terraform_test +0 -0
  22. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/__init__.py +0 -0
  23. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/__main__.py +0 -0
  24. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/api.py +0 -0
  25. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/builder.py +0 -0
  26. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/const.py +0 -0
  27. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/parser.py +0 -0
  28. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/hcl2/py.typed +0 -0
  29. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/mypy.ini +0 -0
  30. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/pylintrc +0 -0
  31. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/pyproject.toml +0 -0
  32. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/SOURCES.txt +0 -0
  33. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/dependency_links.txt +0 -0
  34. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/entry_points.txt +0 -0
  35. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/not-zip-safe +0 -0
  36. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/requires.txt +0 -0
  37. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/python_hcl2.egg-info/top_level.txt +0 -0
  38. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/reports/.gitignore +0 -0
  39. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/requirements.txt +0 -0
  40. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/setup.cfg +0 -0
  41. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/test-requirements.txt +0 -0
  42. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/tox.ini +0 -0
  43. {python_hcl2-7.2.0 → python_hcl2-7.2.1}/tree-to-hcl2-reconstruction.md +0 -0
@@ -7,7 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## \[Unreleased\]
9
9
 
10
- - Nothing Yet
10
+ - Nothing yet.
11
+
12
+ ## \[7.2.1\] - 2025-05-16
13
+
14
+ ### Fixed
15
+
16
+ - More robust escaping for special characters. Thanks, @eranor ([#224](https://github.com/amplify-education/python-hcl2/pull/224))
17
+ - Issue parsing interpolation string as an object key ([#232](https://github.com/amplify-education/python-hcl2/pull/232))
11
18
 
12
19
  ## \[7.2.0\] - 2025-04-24
13
20
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-hcl2
3
- Version: 7.2.0
3
+ Version: 7.2.1
4
4
  Summary: A parser for HCL2
5
5
  Author-email: Amplify Education <github@amplify.com>
6
6
  License: MIT
@@ -77,7 +77,7 @@ EQ : /[ \t]*=(?!=|>)/
77
77
  tuple : "[" (new_line_or_comment* expression new_line_or_comment* ",")* (new_line_or_comment* expression)? new_line_or_comment* "]"
78
78
  object : "{" new_line_or_comment? (new_line_or_comment* (object_elem | (object_elem COMMA)) new_line_or_comment*)* "}"
79
79
  object_elem : object_elem_key ( EQ | COLON ) expression
80
- object_elem_key : float_lit | int_lit | identifier | STRING_LIT | object_elem_key_dot_accessor | object_elem_key_expression
80
+ object_elem_key : float_lit | int_lit | identifier | STRING_LIT | object_elem_key_dot_accessor | object_elem_key_expression | string_with_interpolation
81
81
  object_elem_key_expression : LPAR expression RPAR
82
82
  object_elem_key_dot_accessor : identifier (DOT identifier)+
83
83
 
@@ -353,11 +353,21 @@ class HCLReverseTransformer:
353
353
 
354
354
  @staticmethod
355
355
  def _escape_interpolated_str(interp_s: str) -> str:
356
- # begin by doing basic JSON string escaping, to add backslashes
357
- interp_s = json.dumps(interp_s)
358
-
356
+ if interp_s.strip().startswith('<<-') or interp_s.strip().startswith('<<'):
357
+ # For heredoc strings, preserve their format exactly
358
+ return reverse_quotes_within_interpolation(interp_s)
359
+ # Escape backslashes first (very important to do this first)
360
+ escaped = interp_s.replace('\\', '\\\\')
361
+ # Escape quotes
362
+ escaped = escaped.replace('"', '\\"')
363
+ # Escape control characters
364
+ escaped = escaped.replace('\n', '\\n')
365
+ escaped = escaped.replace('\r', '\\r')
366
+ escaped = escaped.replace('\t', '\\t')
367
+ escaped = escaped.replace('\b', '\\b')
368
+ escaped = escaped.replace('\f', '\\f')
359
369
  # find each interpolation within the string and remove the backslashes
360
- interp_s = reverse_quotes_within_interpolation(interp_s)
370
+ interp_s = reverse_quotes_within_interpolation(f'"{escaped}"')
361
371
  return interp_s
362
372
 
363
373
  @staticmethod
@@ -102,10 +102,12 @@ class DictTransformer(Transformer):
102
102
  # This returns a dict with a single key/value pair to make it easier to merge these
103
103
  # into a bigger dict that is returned by the "object" function
104
104
 
105
- key = self.strip_quotes(str(args[0].children[0]))
106
- value = args[2]
105
+ key = str(args[0].children[0])
106
+ if not re.match(r".*?(\${).*}.*", key):
107
+ # do not strip quotes of a interpolation string
108
+ key = self.strip_quotes(key)
107
109
 
108
- value = self.to_string_dollar(value)
110
+ value = self.to_string_dollar(args[2])
109
111
  return {key: value}
110
112
 
111
113
  def object_elem_key_dot_accessor(self, args: List) -> str:
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '7.2.0'
21
- __version_tuple__ = version_tuple = (7, 2, 0)
20
+ __version__ = version = '7.2.1'
21
+ __version_tuple__ = version_tuple = (7, 2, 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-hcl2
3
- Version: 7.2.0
3
+ Version: 7.2.1
4
4
  Summary: A parser for HCL2
5
5
  Author-email: Amplify Education <github@amplify.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes