-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Added support for MyPy #1972
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
Added support for MyPy #1972
Conversation
While we have been using mypy to fix issues in manim for a while, I think that it's important to be officially part of manim's developer tool kit. |
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 have no experience with MyPy at all, it would be great if someone else could look at the concrete changes here.
I don't particularly like the addition of 7 new dependencies.
manim/_config/__init__.pyi
Outdated
config: Any | ||
frame: Any | ||
|
||
def tempconfig(temp: Union[ManimConfig, dict]) -> _GeneratorContextManager: ... |
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.
Why can these types not be added to the actual code file?
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 capitalized colors are generated in runtime so it does not work.
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.
This comment is not about color.pyi
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.
Ohh sorry. Mypy was interacting weirdly and this seemed to be the most direct solution.
The new dependencies are Dev Dependecys, and you can't get much more maintained than under the python github account + microsoft |
What's the point of mypy? I'm not even sure why we need it. |
Static Type checking. It finds bugs in our documentation & code. If we mark functions for the wrong types it can mislead people. There have already been several prs fixing mypy errors. |
for more information, see https://pre-commit.ci
This looks like something we could really use. What I don't understand is why the |
This pull is old enough that if we plan to merge it, it might be better to delete the pyi files. |
Try only running it on manim's folder. I did not do anything with the testing. |
We should also add this to the |
I've been away for a while, sorry for the really late response. I believe it's too early to add it to pre-commit. That one error was introduced since I made this. |
Could you also merge any new changes to Manim and check if MyPy runs? |
Co-authored-by: Christopher Besch <christopher.besch@gmx.de>
I think everything is up to data and functioning now :) I fixed the logger error as well. |
I also managed to get the mypy pre-commit hook working :) |
I ran it on my machine and everything seems to be working. With pre-commit it is also being run in CI. Thanks for the contribution! |
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 looks good, thank you!
Overview: What does this pull request change?
I added mypy support, including the pre-commit hook, and also fixed some issues mypy brought up.
Many things are ignored, it is a task for future pulls to fix the issues.
Reviewer Checklist