-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add typings #52
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
Comments
One of the main problems with this is contributions from the community. What if a user wants to contribute a PR but they don't have experience with typing? Do we just reject all PRs without types, or do we guide each user in adding types? Or do we merge them and add the types ourselves? |
The latter is more appropriate. In general, the one making the PR should attempt to write the typings themselves. If they do not manage to, we can work this out by ourselves. (Not sure if the usage of stubs would prove itself more useful in this case) |
^we should at least expect PRs to have documentation, which makes writing typings by ourselves trivial |
Good point. |
It seems like we have a pretty solid plan for this. Should we get started? |
I think this should be left until after we are done with the "initial clean up" milestone. |
this should be done in conjunction with the dataclasses change for optimal compatibility and development. |
The latest developments in #7 kinda sound like we won't be using dataclasses. If that's the case, then we can start adding typings at any time, say one module at a time. Any takers? |
I think this is a good place to continue the discussion from #483 (comment) The points I was trying to make:
I'd like to suggest changing our policy from adding typings via docstrings to adding typings via type hints. :-) |
Using in-code typings |
Do you mean having typings in both of them, or separating them?
As I said before: we may do that, however only after we actually get to work on in-code typehints. Until then, we need something to base ourselves on in order to generate typings. |
@PgBiel I meant having in-code and not having in-docstring. What is the benefit of having both? All I could think of is that a user reading the docs might not get the full benefit from in-code, but if Sphinx can be configured to parse in-code and show those to the user, then why bother? |
Are we talking something like this: |
got it
if we can configure that, then it should be fine |
no no, this style of annotation was before the latest typing PEP took place, which ensured that annotations should be exclusively for typings (starting on py 3.5). We are talking about reproducing the typehint syntax in the documentation string of the class/function/... when specifying what a parameter or attribute is, for example. |
I have made #835 which type some parts of code and this can be done for the other parts of the code also. |
Seems like this never went anywhere? Bit of a shame. Makes it way harder to learn for beginners. |
It's work in progress. Type hints have been added to some parts of the library; help for adding them to other parts is warmly welcome. |
This is far too broad an issue to be resolved with one PR. For new contributors/hacktoberfest participants, I recommend working on one file per PR. |
I have added typings to most of I can put up a PR for discussion if you like? |
Sure, that sounds great! |
Here it is: #2129 I put |
I generated typings stubs for manim locally with |
Generate the pattern matrix in blocks
We should add typings to manim:
mypy
and whatnot);Notes:
stubgen
to have a headstart;Thoughts?
The text was updated successfully, but these errors were encountered: