-
-
Notifications
You must be signed in to change notification settings - Fork 104
Improve type safety for dispmethods and enhance tests. #885
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
Merged
Conversation
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #885 +/- ##
==========================================
+ Coverage 84.76% 84.88% +0.11%
==========================================
Files 125 126 +1
Lines 11587 11668 +81
==========================================
+ Hits 9822 9904 +82
+ Misses 1765 1764 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…od calls. Verifies the `WindowsInstaller.Installer` COM object's creation, its pure dispatch nature (non-dual), and its dispmethod calls.
Adds a test for `Installer.RegistryValue`'s key existence check. Also renames a test method for clarity and updates comments.
Adds a test to ensure a `ValueError` is raised when calling a dispmethod with named parameters, which is not yet supported. This acts as a safeguard against invalid calls.
Adds a test for the `Installer.ProductState` property to verify both correct value retrieval and error handling.
Corrected a typo in a comment from "assing" to "assign". Renamed the test method `test_dict` to `test_dynamic` to more accurately reflect that it tests the dynamic dispatch capabilities of `comtypes`.
Updated the comment for the `HashVal` property to clarify that it is a 'hidden' member used internally by `Scripting.Dictionary`, not intended for external use.
…nstants. Replaced magic numbers with `comtypes.gen.Scripting` constants in `comtypes/test/test_dict.py`. This improves readability and maintainability by using named constants from the `scrrun.dll` type library, aligning with official documentation for `Scripting.Dictionary.CompareMode`.
To improve type safety, this change marks all arguments in generated dispmethod stubs as positional-only. This allows static type checkers to catch invalid calls using named arguments, which are not supported.
Modified `DispMethodAnnotator` to prevent adding a positional-only
parameter marker ('/') to method signatures that have no arguments.
This fixes a bug where it would generate inappropriate type hints like `def method(self, /)`.
An additional test case with a no-argument dispmethod (`egg`) was also
added to `test_disp_interface` to verify the fix.
61d092a to
8dc6b01
Compare
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.
#371 (comment)
This pull request enhances testing for
Scripting.DictionaryandWindowsInstaller.Installer, and improves type safety for generated dispmethods.Changes
Refactor and enhance
test_dict.pytest_dynamicwithScriptingconstants.test_staticto verify the behavior ofScripting.IDictionarydual interface.Add
test_msi.pyforWindowsInstaller.InstallerWindowsInstaller.Installerpure dispatch interface.Enforce positional-only arguments for dispmethods (typing)
/).