Skip to content
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

Converted all types of parameters in docstrings to proper type annotations #2988

Merged
merged 6 commits into from Nov 10, 2022

Conversation

NotWearingPants
Copy link
Contributor

@NotWearingPants NotWearingPants commented Oct 12, 2022

Overview: What does this pull request change?

I have gone through all of the types of parameters in docstrings and:

  • If there was no type annotation for that parameter I annotated with the type from the docstring (and added the necessary imports)
  • If there was (so the docstring type is redundant) I checked they were the same and deleted the docstring type
  • If the docstring mentioned a param which does not exist I fixed it
  • Fixed some more docstring issues I found
  • There are now zero types in the "parameters" section of docstrings across the library

Motivation and Explanation: Why and how do your changes improve the library?

Advances progress in #2121 by a lot 🎉
There are still return types and attribute types in docstrings, maybe I'll do them next.

Links to added or changed documentation pages

Further Information and Comments

I wrote a script to help me automate a lot of the process, and manually did what I couldn't automate (the 4th commit).

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@NotWearingPants NotWearingPants marked this pull request as draft October 14, 2022 02:51
@NotWearingPants NotWearingPants marked this pull request as ready for review October 15, 2022 12:26
@NotWearingPants
Copy link
Contributor Author

The first commit was created by running this script I wrote, so if you prefer you can review the script instead of the diff it created.

For the 2nd commit I ran isort and for the 3rd commit I ran black, but the 4th commit was done manually so it also requires reviewing.

@behackl behackl self-requested a review October 27, 2022 11:16
@behackl behackl added the maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements label Oct 27, 2022
Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very impressive work, kudos! I have a bunch of minor suggestions / change requests, but am overall very happy with this. This is indeed a substantial step in the direction of a fully typed library! 🥳

Please let me know if you can take a look at my comments, otherwise I'll work on resolving them in order to get this PR merged ASAP. Thanks!

The new time the animation should take in seconds.

rate_func
The new function defining the animation progress based on the relative runtime (see :mod:`~.rate_functions`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line length

Suggested change
The new function defining the animation progress based on the relative runtime (see :mod:`~.rate_functions`).
The new function defining the animation progress based
on the relative runtime (see :mod:`~.rate_functions`).

pixel_width: int | None = None,
frame_height: float | None = None,
frame_width: float | None = None,
frame_rate: float | None = None,
**kwargs,
):
"""Initialises the Camera.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring of Camera.__init__ should actually live in the class docstring of Camera (otherwise it won't show up in the built documentation).

background : optional
background_image
The path to an image that should be the background image.
If not set, the background is filled with `self.background_color`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If not set, the background is filled with `self.background_color`
If not set, the background is filled with :attr:`background_color`

or

Suggested change
If not set, the background is filled with `self.background_color`
If not set, the background is filled with ``self.background_color``

(I'd prefer the first.)

An integer constant described in the Pillow library,
or one from the RESAMPLING_ALGORITHMS global dictionary,
under the following keys:
* 'bicubic' or 'cubic'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animations
Animation or mobject with mobject method and params
play_kwargs
named parameters affecting what was passed in ``animations``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
named parameters affecting what was passed in ``animations``,
Named parameters affecting what was passed in ``animations``,

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not push my changes here directly, so I have made a PR to your fork: NotWearingPants#1 -- please take a look, I'd like to get this merged rather sooner than later. :-)

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am merging this PR as-is, and will add the remaining changes via a follow-up PR.

Thanks again for your contribution!

@behackl behackl merged commit 95bca6f into ManimCommunity:main Nov 10, 2022
@NotWearingPants
Copy link
Contributor Author

@behackl I'm sorry I wasn't responsive this month so far, I've been busy with school work unfortunately (semester started recently).
Thank you for your efforts to merge the PRs!!
Hopefully I'll find time to work on more stuff here, like converting attribute types from docstrings.

@behackl behackl changed the title Convert all types of parameters in docstrings to proper type annotations Converted all types of parameters in docstrings to proper type annotations Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants