Skip to content

Fix Python projection annotation aliases - #159

Merged
leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-python-annotation-aliases
Sep 18, 2026
Merged

leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-python-annotation-aliases

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Use one consistent module-local and imported type-name mapping for Python handler, delegate, result, and ordinary annotations. Struct aliases now match .py/.pyi imports, self-interface references use the local class name while same-name foreign interfaces remain imported, standalone embedded structs use local names, and nested default constructors remain valid.

Add a focused Alpha/Beta collision fixture covering arrays, delegates, multi-results, and standalone class and struct cases, and document the naming invariants.

Scope and independence

This PR targets main and contains two commits affecting 11 codegen, test, and architecture-documentation files. It contains no collection runtime or docs/status/TODO.md changes and is independent of the collection fix; the two PRs may merge in either order.

JavaScript output and the intentional TypeScript nullable Object getMany change are untouched.

Initial validation

The following validation was completed on the original fix before its cherry-pick; no builds, dependency installation, or test/CI reruns were performed for that initial PR preparation.

  • implementation_naming_test::python_handler_annotations_resolve_colliding_struct_and_interface_names passes, including supported mypy checks and runtime type-hint resolution. The existing winrt_implementation_test::implementation_python_projection also passes.
  • All four snapshot tests pass without snapshot changes, and the final release codegen build succeeds.
  • On the same 22-seed official WinRT/WinAppSDK closure, supported mypy 1.20.2 diagnostics decrease from 723 to 426: all 20 newly introduced handler errors across five files and 277 tightly coupled baseline errors are resolved, with zero new errors versus the retained release baseline. 426 other pre-existing diagnostics remain; Python typing is not entirely clean.
  • All 2,627 generated Python modules import, and the five affected handler protocols resolve type hints using their actual runtime exports.
  • All 2,292 generated JavaScript/declaration/support files are byte-identical, preserving JavaScript output and nullability. The initial standalone follow-up also leaves all 5,261 packaged Python files and 2,292 JavaScript files byte-identical to the previously verified fixed output.

At initial PR creation, git diff --check, the exact 11-file scope, identical source contents, preserved commit trailers, and single-commit ancestry directly on main were verified.

Use consistent local and imported type names in generated handler, delegate, result, and struct annotations. Preserve same-named interfaces from other namespaces and standalone embedded struct names. Add collision and typing regression coverage without changing JavaScript output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdea384f-3022-47e8-8c74-11fd768c2105
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 85.72% 80.88% 85.25% regions
Python aggregate 71.06% n/a 37.9% branches
Python runtime 99.12% n/a 97.37% branches
Generated Python WinRT projections 70.05% n/a 27.07% branches
Generated Python WinRT implementations 72.29% n/a 47.04% branches
JavaScript aggregate 22.14% 25.21% 57.88% branches
JavaScript runtime 44.27% 45.76% 78.99% branches
Generated WinRT projections 22.97% 18.71% 54.94% branches
Generated WinRT implementations 48.66% 59.76% 61.14% branches
Generated Classic COM projections 11.92% 23.97% 54.2% branches

View workflow run and download full HTML/LCOV/XML reports

Bind standalone struct references to their actual declared names and compare canonical identities when excluding Python self imports. Add generic-versus-named collision regressions for standalone and packaged projections while preserving JavaScript output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lei9444
leileizhang (lei9444) merged commit dbf461a into main Sep 18, 2026
24 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-python-annotation-aliases branch September 18, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants