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

Add typings to manim/__main__.py #4007

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,49 @@
import click
import cloup

from . import __version__, cli_ctx_settings, console
from .cli.cfg.group import cfg
from .cli.checkhealth.commands import checkhealth
from .cli.default_group import DefaultGroup
from .cli.init.commands import init
from .cli.plugins.commands import plugins
from .cli.render.commands import render
from .constants import EPILOG
from manim import __version__
from manim._config import cli_ctx_settings, console
from manim.cli.cfg.group import cfg
from manim.cli.checkhealth.commands import checkhealth
from manim.cli.default_group import DefaultGroup
from manim.cli.init.commands import init
from manim.cli.plugins.commands import plugins
from manim.cli.render.commands import render
from manim.constants import EPILOG


def show_splash(ctx, param, value):
def show_splash(ctx: click.Context, param: click.Option, value: str | None) -> None:
"""When giving a value by console, show an initial message with the Manim
version before executing any other command: ``Manim Community vA.B.C``.

Parameters
----------
ctx
The Click context. Unused parameter.
param
A Click option. Unused parameter.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to mention that it is unused here? It just seems like something that's easy to forget if we ever change it to actually use the parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, so I removed that mention.

value
A string value given by console, or None. Unused parameter.
"""
if value:
console.print(f"Manim Community [green]v{__version__}[/green]\n")


def print_version_and_exit(ctx, param, value):
def print_version_and_exit(
ctx: click.Context, param: click.Option, value: str | None
) -> None:
"""Same as :func:`show_splash`, but also exit when giving a value by
console.

Parameters
----------
ctx
The Click context. Unused parameter.
param
A Click option. Unused parameter.
value
A string value given by console, or None. Unused parameter.
"""
show_splash(ctx, param, value)
if value:
ctx.exit()
Expand Down Expand Up @@ -53,8 +80,14 @@ def print_version_and_exit(ctx, param, value):
expose_value=False,
)
@cloup.pass_context
def main(ctx):
"""The entry point for manim."""
def main(ctx: click.Context) -> None:
"""The entry point for Manim.

Parameters
----------
ctx
The Click context.
"""
pass


Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ ignore_errors = True
ignore_errors = False
warn_return_any = False

[mypy-manim.__main__]
ignore_errors = True


# ---------------- We can't properly type this ------------------------

Expand Down
Loading