REFACTOR: Improve type hint in generics#7931
Open
SMoraisAnsys wants to merge 5 commits into
Open
Conversation
SMoraisAnsys
requested review from
Copilot,
eblanco-ansys,
ecoussoux-ansys and
maxcapodi78
July 23, 2026 07:02
There was a problem hiding this comment.
Pull request overview
This PR refactors several “generic” utilities to improve type-hint accuracy and type-checker compatibility (per #7888 / #5194), adding Protocol-based interfaces for AEDT COM objects and narrowing ambiguous types in common helpers.
Changes:
- Added new AEDT COM Protocol interfaces (
_ODesktop,_ODesign) and refined existing Protocol typing (e.g.,_OProject.GetTopDesignList). - Updated
get_pyaedt_appand other helpers with safer type narrowing (cast, helper parsing functions) and improved optional typing. - Refined unit conversion typing/logic in
constants.pyand adjustedtyexclusions to type-check more ofgeneric/.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ansys/aedt/core/generic/protocols.py | Adds new Protocols for desktop/design COM objects and tightens a project API return type. |
| src/ansys/aedt/core/generic/design_types.py | Adds type-narrowing helpers/casts and refines return typing for get_pyaedt_app. |
| src/ansys/aedt/core/generic/data_handlers.py | Introduces a small helper for regex narrowing and updates type hints for optional args. |
| src/ansys/aedt/core/generic/constants.py | Adds type aliases/helper for callable unit entries and refactors unit_converter branching. |
| pyproject.toml | Narrows tool.ty exclusions from the whole generic/ package to a specific file allowlist. |
| doc/changelog.d/7931.miscellaneous.md | Adds a changelog entry for the generics typing improvements. |
…nsys/pyaedt into refactor/improve-type-hint-in-generics
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.
Description
As title says, follows #7888.
Issue linked
Related to #5194
Checklist