Skip to content

Commit 25191f8

Browse files
committed
fix: provide support for cdktf get's post processing regex
1 parent 4567a06 commit 25191f8

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

packages/jsii-pacmak/lib/targets/python.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,11 @@ class PythonModule implements PythonType {
19161916
'# At runtime TYPE_CHECKING is False, preserving lazy loading.',
19171917
);
19181918
code.openBlock('if typing.TYPE_CHECKING');
1919+
// `pass` keeps this block syntactically valid even if a downstream
1920+
// consumer strips the relative imports below (e.g. cdktf's codegen
1921+
// post-processing removes `from . import ...` lines). Without it, such
1922+
// stripping would leave an empty `if` block and an IndentationError.
1923+
code.line('pass');
19191924
for (const name of submoduleNames) {
19201925
code.line(`from . import ${name} as ${name}`);
19211926
}

packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap

Lines changed: 14 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)