You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python-imports-4-review.md
+18-23Lines changed: 18 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,21 +72,13 @@ instead of the full 11-line class definition. Since `jsii` is already imported b
72
72
73
73
### 3. [Medium]`emitLazyProxyAssignments` silently drops non-empty items at runtime
74
74
75
-
**Status: Not a real concern today**
76
-
77
-
The `emitLazyProxyAssignments` method filters with:
78
-
79
-
```typescript
80
-
.filter(([, items]) =>items.has(''))
81
-
```
82
-
83
-
If there were ever a `PythonImports` entry with non-empty items (e.g., `from foo import Bar`), it would appear in the `TYPE_CHECKING` block but have **no runtime equivalent** in the `else` branch.
75
+
**Status: FIXED**
84
76
85
-
**Verified:** All `requiredImport` entries in `type-name.ts` use `item: ''`. There are exactly two code paths that produce `requiredImport` objects (foreign assembly imports at line 390, same-assembly cross-submodule imports at line 420), and both set `item: ''`. The old per-type import pattern (`item: 'TypeName as _TypeName_hash'`) was completely replaced by the new module-level approach. There is no code path that currently produces non-empty items for cross-module imports.
77
+
The `emitLazyProxyAssignments` method previously filtered with `.filter(([, items]) => items.has(''))`, which would silently skip any import entry with non-empty items — meaning it would appear in the `TYPE_CHECKING` block for type checkers but have no runtime equivalent.
86
78
87
-
The `emitImportStatements` method (in the `TYPE_CHECKING` block) does handle both empty and non-empty items correctly, so type checkers would see correct imports regardless.
79
+
**Fix:** Replaced the silent filter with an explicit assertion that throws an error if any non-empty items are encountered. This ensures that if a new import pattern is ever introduced in `type-name.ts`, the code generator will fail loudly at build time rather than producing subtly broken runtime code.
88
80
89
-
**Action:**Optional — add a comment in `emitLazyProxyAssignments` noting that only full-module imports (empty item) are expected. Not blocking.
81
+
**Verified:**All current code paths produce `item: ''` (two locations in `type-name.ts`), so the assertion never fires today — it's purely a safety net for future changes.
90
82
91
83
---
92
84
@@ -150,16 +142,13 @@ The review suggests relative imports would work without installation, but:
0 commit comments