-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python testing mypy conformance #38165
Python testing mypy conformance #38165
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances mypy conformance for the Python testing modules by adding new type stub (.pyi) files, updating type annotations, and introducing a CI workflow for mypy validation.
- Added type stub files for tasks, pics, apps, and package init in the chip.testing module.
- Updated type annotations and function signatures in testing code and tests to align with stricter type checking.
- Introduced a GitHub Actions workflow to validate type correctness using mypy.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/tasks.pyi | Added type stubs for tasks signatures. |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/pics.pyi | Added type stubs for pics functions. |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/apps.pyi | Added type stubs for apps and subprocess classes. |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/init.pyi | Provided a stub file for the chip.testing package. |
src/python_testing/matter_testing_infrastructure/chip/testing/tasks.py | Updated wait() method’s return type for consistency with type stubs. |
src/python_testing/matter_testing_infrastructure/chip/testing/taglist_and_topology_test.py | Refined type hints and annotations in helper functions and test cases. |
src/python_testing/matter_testing_infrastructure/chip/testing/pics.py | Improved XML parsing by adding checks for missing elements. |
.github/workflows/mypy-validation.yml | Added a CI workflow for mypy validation on selected files. |
Files not reviewed (1)
- src/python_testing/matter_testing_infrastructure/mypy.ini: Language not supported
PR #38165: Size comparison from 0b71b04 to 0c40401 Full report (75 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
PR #38165: Size comparison from 1560a87 to a5a6063 Full report (70 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, psoc6, qpg, stm32, telink, tizen)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left little comments
src/python_testing/matter_testing_infrastructure/chip/testing/pics.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds type annotations and stubs for matter testing code to ensure mypy conformance while also introducing a new CI workflow for type validation.
- Introduces type stub files for tasks, pics, and apps under chip/typings
- Updates type hints and error reporting in testing code (tasks.py, taglist_and_topology_test.py, pics.py)
- Adds a GitHub Actions workflow to run mypy on a subset of files
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/tasks.pyi | Added type stubs for subprocess tasks |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/pics.pyi | Added type stubs for pics functions |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/apps.pyi | Added type stubs for app server subprocess classes |
src/python_testing/matter_testing_infrastructure/chip/typings/chip/testing/init.pyi | Created package stub for chip.testing |
src/python_testing/matter_testing_infrastructure/chip/testing/tasks.py | Updated return type of the wait method for improved type checking |
src/python_testing/matter_testing_infrastructure/chip/testing/taglist_and_topology_test.py | Enhanced type annotations, added type ignore comments where necessary, and standardized type hints |
src/python_testing/matter_testing_infrastructure/chip/testing/pics.py | Improved error messages during XML parsing with robust checks for missing elements/text |
.github/workflows/mypy-validation.yml | Added a new CI workflow to run mypy validation on selected testing files |
Files not reviewed (1)
- src/python_testing/matter_testing_infrastructure/mypy.ini: Language not supported
* mypy type stubs for apps and tasks * fix mypy warnings in taglist_and_topology_test.py * fix mypy warnings in pics.py * gh action yml * gh workflow update * run mypy from python env * debug * fix filename * resolve mypy warnings in taglist file * ignore mypy warning * linter fixes * lint fix 2 * resolve review comments
* mypy type stubs for apps and tasks * fix mypy warnings in taglist_and_topology_test.py * fix mypy warnings in pics.py * gh action yml * gh workflow update * run mypy from python env * debug * fix filename * resolve mypy warnings in taglist file * ignore mypy warning * linter fixes * lint fix 2 * resolve review comments
Basically reusing existing mypy installation to check for a typing issues in matter testing code. Only couple of files are being checked to keep this PR small. Also added the CI workflow. Please let me know if the approach is reasonable and I can continue with keeping other files conformant in a similar fashion.
Testing
Local and CI testing
Fixes #37749