refactor: add type annotations to Shape.__init__ and key methods#1836
Open
refactor: add type annotations to Shape.__init__ and key methods#1836
Conversation
- Add Optional[str] to label, shape_type, description - Add Optional[QtGui.QColor] to line_color - Add Optional[dict[str, bool]] to flags - Add Optional[int] to group_id - Add Optional[NDArray[np.bool_]] to mask - Add type annotations to addPoint, insertPoint, setShapeRefined - Add type annotations to nearestVertex, nearestEdge (return Optional[int]) - Import Optional from typing, NDArray from numpy.typing No logic changes.
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.
Summary
Add type annotations to
Shape.__init__and key methods inlabelme/shape.py. No logic changes.Changes
__init__: annotated all parameters (label,line_color,shape_type,flags,group_id,description,mask) with proper Optional typessetShapeRefined: annotatedshape_type: str,points: list[QtCore.QPointF],point_labels: list[int],mask: Optional[NDArray[np.bool_]]addPoint: annotatedpoint: QtCore.QPointF,label: intinsertPoint: annotatedi: int,point: QtCore.QPointF,label: intnearestVertex: annotatedpoint: QtCore.QPointF,epsilon: float→Optional[int]nearestEdge: annotatedpoint: QtCore.QPointF,epsilon: float→Optional[int]from typing import Optionalandfrom numpy.typing import NDArrayPart of the ongoing type annotation effort (#1832, #1833).