Repository navigation
fix: add py.typed marker and make the package pass mypy - #176
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mypy rejects a conditional expression in a base-class list, so all 15 mixins were treated as untyped. ImageMixinBase is the _ImageBase Protocol for type checkers and object at run time. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- import findpeaks, plot_labelbox and DTYPE_ALIASES from their own modules (the package-level star imports are invisible to mypy; findpeaks was also seen as a module, not the function) - declare _stats and _plane_stats in the _ImageBase Protocol - ImageTensor.Tensor returns Self; quote the ImageReshape meshgrid self type - np.vstack for the deprecated np.row_stack, PIL Resampling.LANCZOS, cv2.MSER.create, explicit SE3 import in mvtbtool Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_ImageBase - ImageIO: a named cmap string is now resolved before set_bad (it raised AttributeError for str); widen the cmap type - imtool: declare the cs_image/colorspace globals; stop reusing val for a list - ImageMultiview, ImageConstants, ImageColor, ImageWholeFeatures: stop reusing one name for a list and then an array; annotate numeric locals - __init__: import findpeaks and meshgrid from their own modules - ImageCore: TYPE_CHECKING-only function so mypy reports any _ImageBase member that Image does not implement Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eatures Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wwfv() now returns the vector for non-1-D slices instead of None; Fiducial.draw() raises ValueError when intrinsics or pose are missing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…or, base/shapes BundleAdjust.optimize(animate=True) referred to undefined names and raised NameError; it now plots the graph with self.plot(). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mpl_styling() no longer raises TypeError when defaults or kwargs is None, and idisp() handles colororder=None for colour images. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
convolve(border='pad', bordervalue!=0) raised NameError; it now pads, filters and crops back. labels_binary() error path and rankfilter() string ranks no longer reference undefined names. Removes the unused _border_args_cv helper. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Methods that return a new image of the same class are now typed Self. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FeatureMatch.by_id1() and by_id2() returned None on their first call, and by_id2() indexed on the wrong column so it never matched. draw() no longer raises TypeError when the caller passes fontsize. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fixes references to undefined names (Animate, plot, history, pt, plotpose) and a verbose-mode AttributeError in IBVS_e. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mypy now reports no errors across the package. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Closes #152 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 5 high |
🟢 Metrics -2 complexity · -2 duplication
Metric Results Complexity -2 Duplication -2
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Remove imports left unused by the typing changes, replace the asserts added for mypy with explicit errors, import Any explicitly in ImageCore and drop two unused locals in VisualServo. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Closes #152. Also moves Issue #40 (adopt mypy) forward.
Adds the empty
py.typedmarker (confirmed present in the built wheel) so type checkers use MVTB's annotations. To make that safe, mypy now reports zero errors, down from 539.Changes:
_ImageBaseProtocolSelfReal bugs found by the type check and fixed:
Image.convolve(border="pad", bordervalue!=0)raised NameErrorFeatureMatch.by_id1()returned None on its first call, andby_id2()never matchedBundleAdjust.optimize(animate=True)raised NameErrormpl_styling()raised TypeError whendefaultsorkwargswas NoneVisualServoreferenced undefined names (Animate,plot,history)Image.disp(cmap="name")withbadcolorraised AttributeErrorBaseFeature2D.draw()raised TypeError iffontsizewas passedBagOfWords.wwfv()returned None for non-1-D slicesSome third-party stub errors (open3d, OpenCV, rosbags) are silenced with
# type: ignore. mypy is not yet in CI; that is a separate PR.Tests: 1427 passed, 35 skipped. AI-assisted (Claude Code), commits carry a Co-Authored-By trailer.
🤖 Generated with Claude Code