Skip to content

Enhance type annotations in tlbparser and codegenerator ahead of addressing the VT_I1 mapping issue. - #973

Merged
junkmd merged 13 commits into
enthought:mainfrom
junkmd:enhance_type_annos_to_tlbparser_and_codegen
Oct 21, 2026
Merged

junkmd merged 13 commits into
enthought:mainfrom
junkmd:enhance_type_annos_to_tlbparser_and_codegen

Conversation

@junkmd

@junkmd junkmd commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces explicit type annotations to tlbparser and codegenerator (notably introducing the ParsedType union) and cleans up related type definitions and imports.

This is a preparatory refactoring intended to provide type annotations ahead of addressing the VT_I1 mapping issue(#969), ensuring subsequent refactorings proceed smoothly and safely.

Except for the constructor of FundamentalType (which was verified through codebase investigation to be safe to modify in order to uphold the type contract), all changes in this PR intentionally avoid modifying runtime behavior.
While replacing Any with stricter type annotations leads to type checker warnings due to the lack of runtime type-narrowing in the existing code, we have intentionally scoped this PR to avoid altering runtime logic at this stage.

@junkmd junkmd added this to the 1.5.0 / Support Python 3.15 milestone Oct 21, 2026
@junkmd junkmd added enhancement New feature or request typing related to Python static typing system coding style Topics related to style, formatters, linters, and delinting. labels Oct 21, 2026
@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.56%. Comparing base (bfe275a) to head (4053b50).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #973      +/-   ##
==========================================
+ Coverage   89.55%   89.56%   +0.01%     
==========================================
  Files         143      143              
  Lines       14147    14170      +23     
==========================================
+ Hits        12669    12692      +23     
  Misses       1478     1478              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@junkmd junkmd changed the title Enhance type annotations in tlbparser and codegenerator ahead of VT_I1 refactoring. Enhance type annotations in tlbparser and codegenerator ahead of addressing VT_I1 mapping. Oct 21, 2026
@junkmd junkmd changed the title Enhance type annotations in tlbparser and codegenerator ahead of addressing VT_I1 mapping. Enhance type annotations in tlbparser and codegenerator ahead of addressing the VT_I1 mapping. Oct 21, 2026
@junkmd junkmd changed the title Enhance type annotations in tlbparser and codegenerator ahead of addressing the VT_I1 mapping. Enhance type annotations in tlbparser and codegenerator ahead of addressing the VT_I1 mapping issue. Oct 21, 2026
@junkmd
junkmd force-pushed the enhance_type_annos_to_tlbparser_and_codegen branch 2 times, most recently from 2695fee to 2850905 Compare October 21, 2026 02:39
junkmd and others added 13 commits October 21, 2026 02:42
There used to be a special-case path for `name="void"` where instance
attributes `size` and `align` were not assigned, but in the current
implementation that branch is already guarded by the type identity itself, so it
is not a realistic runtime problem. In other words, `void` is already treated as
an exceptional case at the parser boundary, and the implementation does not
expect a generic attribute test such as `hasattr`/`getattr` to be needed for
it.

The policy here is to treat `void` as a sentinel value in this type parser even
though C itself defines it as an incomplete type, for which `sizeof(void)` is
not meaningful. `FundamentalType` is not a perfect model of C types; it is a
Python-side representation that needs to expose `size` and `align` as
attributes for downstream code to consume consistently. In that model, the
`(0, 0)` assignment keeps `void` consistent without requiring a special case in
the downstream code.

This is therefore not a claim that `void` is a true zero-sized, zero-aligned C
object in the language-theoretic sense; it is simply the parser's policy for
encoding an incomplete type in a model that requires those fields to exist.
@junkmd
junkmd force-pushed the enhance_type_annos_to_tlbparser_and_codegen branch from 2850905 to 4053b50 Compare October 21, 2026 02:42
@junkmd
junkmd merged commit c4fe55d into enthought:main Oct 21, 2026
223 of 226 checks passed
@junkmd
junkmd deleted the enhance_type_annos_to_tlbparser_and_codegen branch October 21, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding style Topics related to style, formatters, linters, and delinting. enhancement New feature or request typing related to Python static typing system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants