-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Type annotation work in manim/mobject/geometry/ #3961
base: main
Are you sure you want to change the base?
Type annotation work in manim/mobject/geometry/ #3961
Conversation
The following four errors are removed with the commit. manim/mobject/geometry/labeled.py:63: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/labeled.py:70: error: Incompatible default for argument "frame_fill_color" (default has type "None", argument has type "ManimColor | int | str | tuple[int, int, int] | tuple[float, float, float] | <6 more items>") [assignment] manim/mobject/geometry/labeled.py:82: error: Incompatible types in assignment (expression has type "MathTex | Text", variable has type "MathTex") [assignment] manim/mobject/geometry/labeled.py:150: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
The following errors are removed with the commit. manim/mobject/geometry/tips.py:115: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:208: error: Function is missing a type annotation [no-untyped-def] manim/mobject/geometry/tips.py:232: error: Function is missing a return type annotation [no-untyped-def] manim/mobject/geometry/tips.py:245: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:273: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:282: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:301: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:310: error: Function is missing a type annotation for one or more arguments [no-untyped-def] manim/mobject/geometry/tips.py:333: error: Function is missing a type annotation for one or more arguments [no-untyped-def] The following errors are still present: manim/mobject/geometry/tips.py:167: error: Unsupported left operand type for - ("tuple[float, float, float]") [operator] manim/mobject/geometry/tips.py:167: note: Both left and right operands are unions manim/mobject/geometry/tips.py:230: error: Argument 1 to "scale" of "Mobject" has incompatible type "floating[Any]"; expected "float" [arg-type]
TypeErrorCount: 1773
Hey thanks for helping out with the typing!
Most likely, you shouldn't be using the |
Thanks for the tip about My plan is to focus on getting rid of most of these errors:
Now the type of errors reported by mypy for the files in mobject/geometry looks like shown below.
|
A lot of those are quite difficult (mostly because Manim was not designed with typing in mind!) I would just For ones about returning If it's being annoying about numpy arrays being a If you need any more help or the PR is ready to review feel free to tag me :) P.S. this might be useful https://docs.manim.community/en/latest/contributing/docs/types.html |
Overview: What does this pull request change?
The pull request is meant as a first step towards getting the automatic type annotations (mypy) to work on the codebase.
Motivation and Explanation: Why and how do your changes improve the library?
I found this issue listed as as "good first issue"
#2121
This lead to this issue
#3375
Further Information and Comments
The main issue that I am struggling with at the moment, are type errors like the one listed below
The issue is that mypy do not think that two Point3D objects can be subtracted from each other.
This operation is performed in multiple locations of the codebase, e.g. line 180 in arc.py
angles = cartesian_to_spherical(handle - anchor)
Reviewer Checklist