-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add typing annotations to svg_mobject.py #4318
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
@@ -509,11 +510,11 @@ def init_points(self) -> None: | |||
|
|||
def handle_commands(self) -> None: | |||
all_points: list[np.ndarray] = [] | |||
last_move = None | |||
last_move: np.ndarray = None |
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.
The np.ndarray
type seems to work here. But is there any better? I don't think it should be Point3DLike
.
@@ -121,10 +122,10 @@ | |||
self.color = color | |||
self.opacity = opacity | |||
self.fill_color = fill_color | |||
self.fill_opacity = fill_opacity | |||
self.fill_opacity = fill_opacity # type: ignore[assignment] |
Check warning
Code scanning / CodeQL
Overwriting attribute in super-class or sub-class Warning
VMobject
self.stroke_color = stroke_color | ||
self.stroke_opacity = stroke_opacity | ||
self.stroke_width = stroke_width | ||
self.stroke_opacity = stroke_opacity # type: ignore[assignment] |
Check warning
Code scanning / CodeQL
Overwriting attribute in super-class or sub-class Warning
VMobject
@@ -121,10 +122,10 @@ def __init__( | |||
self.color = color | |||
self.opacity = opacity | |||
self.fill_color = fill_color | |||
self.fill_opacity = fill_opacity | |||
self.fill_opacity = fill_opacity # type: ignore[assignment] |
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.
The type annotations for the SVGMobject
allows this value to be None
, which is not compatible with the superclass VMobject
. It seems to be fixed using some kind of default SVG value magic a few lines later.
self.stroke_opacity = stroke_opacity # type: ignore[assignment] | ||
self.stroke_width = stroke_width # type: ignore[assignment] |
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.
Same as above.
@@ -435,7 +436,7 @@ def text_to_mobject(text: se.Text): | |||
The parsed SVG text. | |||
""" | |||
logger.warning(f"Unsupported element type: {type(text)}") | |||
return | |||
return # type: ignore[return-value] |
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.
Can we get rid of this mypy ignore statement?
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.
I think this is fine for a first round; systemic issues with allowed overwritten values will have to be treated differently anyways.
Thank you very much!
self.stroke_opacity = stroke_opacity | ||
self.stroke_width = stroke_width | ||
self.stroke_opacity = stroke_opacity # type: ignore[assignment] | ||
self.stroke_width = stroke_width # type: ignore[assignment] |
Check warning
Code scanning / CodeQL
Overwriting attribute in super-class or sub-class Warning
Overview: What does this pull request change?
Reviewer Checklist