Skip to content

Commit 992b568

Browse files
authored
fix(jinja2): upgrade jinja2 and markupsafe (#943)
* Update Jinja2 templates to check for schema.required being defined * Update PackageLoader for Jinja2 to root of package instead of core/contract for template searching * Unpin Jinja2 and MarkupSafe * gitattributes to set line endings
1 parent 14ab4ff commit 992b568

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text eol=lf

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def find_version(*file_paths):
3939
python_requires=">=3.6",
4040
install_requires=[
4141
"boto3>=1.10.20",
42-
"Jinja2==2.11.3",
43-
"markupsafe==2.0.1",
42+
"Jinja2>=2.11.3",
43+
"markupsafe>=2.0.1",
4444
"jsonschema>=3.0.1,<4.0",
4545
"pytest>=4.5.0",
4646
"pytest-random-order>=1.0.4",

src/rpdk/core/contract/hook_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def _update_schema(self, schema):
132132
trim_blocks=True,
133133
lstrip_blocks=True,
134134
keep_trailing_newline=True,
135-
loader=PackageLoader(__name__, "templates/"),
135+
# Unable to use __name__ anymore after Jinja2 3.x change
136+
loader=PackageLoader("rpdk.core", "templates/"),
136137
autoescape=select_autoescape(["html", "htm", "xml", "md"]),
137138
)
138139
self._schema = schema

src/rpdk/core/templates/docs-readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ Properties:
5252
{{ prop.description }}
5353
{% endif %}
5454

55-
_Required_: {% if propname in schema.required %}Yes{% else %}No{% endif %}
56-
55+
{% if schema.required is defined and propname in schema.required %}
56+
_Required_: Yes
57+
{% else %}
58+
_Required_: No
59+
{% endif %}
5760

5861
_Type_: {{ prop.longformtype }}
5962
{% if prop.allowedvalues %}

src/rpdk/core/templates/docs-subproperty.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ To declare this entity in your AWS CloudFormation template, use the following sy
4747
{{ prop.description }}
4848
{% endif %}
4949

50-
_Required_: {% if propname in schema.required %}Yes{% else %}No{% endif %}
51-
50+
{% if schema.required is defined and propname in schema.required %}
51+
_Required_: Yes
52+
{% else %}
53+
_Required_: No
54+
{% endif %}
5255

5356
_Type_: {{ prop.longformtype }}
5457
{% if prop.allowedvalues %}

src/rpdk/core/templates/hook-docs-readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ To activate a hook in your account, use the following JSON as the `Configuration
4343
{{ prop.description }}
4444
{% endif %}
4545

46-
_Required_: {% if propname in schema.required %}Yes{% else %}No{% endif %}
47-
46+
{% if schema.required is defined and propname in schema.required %}
47+
_Required_: Yes
48+
{% else %}
49+
_Required_: No
50+
{% endif %}
4851

4952
_Type_: {{ prop.longformtype }}
5053
{% if prop.allowedvalues %}

0 commit comments

Comments
 (0)