-
Notifications
You must be signed in to change notification settings - Fork 102
🔧 mypy type check tools/ and utils/
#931
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
Conversation
for more information, see https://pre-commit.ci
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 pull request revisits several files in the tools and utils directories to update type annotations and improve type safety. Key changes include the adoption of explicit type annotations for contour arrays in visualization, refined output size handling in transforms, and improved type annotations for feature extraction and patch extraction components.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tiatoolbox/utils/visualization.py | Updated contour type annotation and replaced numpy array conversion with cv2.Mat for drawing functions. |
| tiatoolbox/utils/transforms.py | Modified cv2.resize dsize parameter to explicitly construct a size tuple. |
| tiatoolbox/tools/registration/wsi_registration.py | Updated type annotations and cast usages for feature extraction components. |
| tiatoolbox/tools/patchextraction.py | Revised input_mask type declarations to include AnnotationStore. |
Comments suppressed due to low confidence (3)
tiatoolbox/tools/registration/wsi_registration.py:341
- [nitpick] Consider whether using torch.Tensor() as a placeholder is appropriate; if these feature tensors are uninitialized, an Optional type (or using None) might better convey the intended semantics.
self.features: dict[str, torch.Tensor] = dict.fromkeys(output_layers_key, torch.Tensor())
tiatoolbox/utils/visualization.py:485
- Ensure that using cv2.Mat for converting contours is supported by your target OpenCV version, as the Python API typically expects numpy arrays for cv2.drawContours.
[cv2.Mat(inst_contour)]
tiatoolbox/utils/visualization.py:886
- Verify that converting the contour to cv2.Mat here is intentional and compatible with cv2.polylines in your OpenCV version; traditionally, numpy arrays are used.
[cv2.Mat(cnt)]
mypy type check tools/ and utils/mypy type check tools/ and utils/
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #931 +/- ##
========================================
Coverage 99.70% 99.70%
========================================
Files 71 71
Lines 8847 8851 +4
Branches 1154 1154
========================================
+ Hits 8821 8825 +4
Misses 23 23
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 updates type annotations and typing usage in the tools and utils directories to improve mypy type checking.
- Adds explicit type annotations in visualization and transforms modules.
- Revises type declarations and cast usage in the wsi_registration module.
- Adjusts input type handling in the patchextraction module.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tiatoolbox/utils/visualization.py | Added explicit type annotations for contours and polylines in visualization. |
| tiatoolbox/utils/transforms.py | Refined the dsize parameter by converting output_size_array to a tuple. |
| tiatoolbox/tools/registration/wsi_registration.py | Updated type annotations, cast usage, and function signatures in feature extraction. |
| tiatoolbox/tools/patchextraction.py | Improved input_mask type checks and updated imports for AnnotationStore. |
Revisited some of the files from
tools/ andutils/, updated typing for them.