Skip to content

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Jul 21, 2025

This PR introduces several improvements to the util module, focusing on modernizing the code.

Key Changes:

Explicit imports

Replaces the wildcard import (from ctypes import *) with explicit imports.

Improved type hinting

Adds typing.overload to byref_at and cast_field.

Code cleanup

Removes several unused parameters from the cast_field function, simplifying its signature.
Removes the corresponding F403 and F405 ignore rules from pyproject.toml now that wildcard imports are no longer used in util.py.

junkmd added 5 commits July 21, 2025 08:58
These are no longer needed since the wildcard import was replaced by
explicit imports.
Removes several parameters from the `cast_field` function signature
that were no longer being used.
@junkmd junkmd added this to the 1.4.12 milestone Jul 21, 2025
@junkmd junkmd added typing related to Python static typing system coding style Topics related to style, formatters, linters, and delinting. labels Jul 21, 2025
@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.75%. Comparing base (5e241d8) to head (132540a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #866      +/-   ##
==========================================
+ Coverage   84.73%   84.75%   +0.01%     
==========================================
  Files         125      125              
  Lines       11559    11571      +12     
==========================================
+ Hits         9795     9807      +12     
  Misses       1764     1764              

☔ View full report in Codecov by Sentry.
📢 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 marked this pull request as ready for review July 21, 2025 01:05
@junkmd junkmd merged commit 6a580b3 into enthought:main Jul 21, 2025
98 of 101 checks passed
@junkmd junkmd deleted the refactor_util branch July 21, 2025 01:06
junkmd added a commit to junkmd/comtypes that referenced this pull request Jul 21, 2025
…ght#866)

* Use explicit imports in `util`.

* Remove unnecessary ruff ignores for `util.py`.
These are no longer needed since the wildcard import was replaced by
explicit imports.

* Remove unused parameters from `cast_field`.
Removes several parameters from the `cast_field` function signature
that were no longer being used.

* Add overloads to `util.byref_at` for improved type hinting.

* Add overloads to `util.cast_field` for improved type hinting.

* Replace  `Type[_SimpleCData[_T]]` with `Type["_SimpleCData[_T]"]`.
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. typing related to Python static typing system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant