Repository navigation
Reorganize automation - typeinfo module dependency structure. - #987
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## safearray_typeinfo_dep #987 +/- ##
==========================================================
+ Coverage 87.16% 90.80% +3.64%
==========================================================
Files 149 149
Lines 15993 15466 -527
==========================================================
+ Hits 13940 14044 +104
+ Misses 2053 1422 -631 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
junkmd
added a commit
that referenced
this pull request
Nov 12, 2026
junkmd
added a commit
that referenced
this pull request
Nov 12, 2026
* Refactor: Move `IRecordInfo` and related functions to `recordinfo` module. * Refactor: Move `SafeArrayGetRecordInfo` to `recordinfo` module and update references. * Refactor: Update import statements to move `GetRecordInfoFromGuids` and `IRecordInfo` from `typeinfo` to `recordinfo` module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This package models COM, but a Python module also models its complexity.
Because the modules depend on each other, we cannot remove lazy imports and make the direction of dependency completely one-way. Still, there are parts we can organize.
For example,
typeinfodepends onautomation, but it should be the other way around. We will sort out this situation to make future feature development and debugging easier.Changes
1. Split
automation.pyinto_automation.pyandautomation.py_automation.pycontaining the low-level automation types (VARIANT,tagCY,tagDEC,VARTYPE,DISPID, etc.) and helper functions (_ctype_to_vartype,_vartype_to_ctype,_arraycode_to_vartype, fixed-point number marshaling helpers).automation.pybecomes a thin re-export layer over_automation.pyfor backward compatibility.typeinfo.pynow imports these from_automationinstead of fromautomation.Rationale:
typeinfowas importing fromautomation, creating a dependency direction that is backwards from what the type hierarchy would suggest. By splittingautomationinto a low-level_automation(no internal deps) and a thinautomationre-export layer,typeinfocan depend on_automationdirectly, avoiding circular imports.2. Split
typeinfo.pyintorecordinfo.pyandtypeinfo.pyrecordinfo.pycontaining:IRecordInfointerfaceGetRecordInfoFromTypeInfoGetRecordInfoFromGuidsSafeArrayGetRecordInfotypeinfo.py, replacing with re-exports fromrecordinfo.Rationale:
IRecordInfoand its factory functions were previously bundled insidetypeinfo.py. Extracting them into a dedicatedrecordinfomodule makes the dependency graph clearer and reduces the surface area oftypeinfo.3. Remove lazy imports from
safearray.pyfrom comtypes.automation import ...andfrom comtypes.typeinfo import ...inside functions insafearray.pyhave been moved to module-level imports at the bottom of the file.safearray.pynow imports fromcomtypes._automation,comtypes.automation, andcomtypes.recordinfodirectly.Rationale: Lazy imports inside functions were a workaround for circular dependencies. With the module reorganization, these circular dependencies are resolved, so the imports can be made at module level. This makes the code easier to read, debug, and analyze statically.
4. Move
tagSAFEARRAYBOUNDto_safearray.pytagSAFEARRAYBOUNDandSAFEARRAYBOUNDare now defined in_safearray.pyand re-imported bytypeinfo.py.Rationale: These types belong with the SAFEARRAY infrastructure, not with the typeinfo module.
Dependency Graph (After)