From 917fa972ccac3cfede75e19cdfdc67ab25e9a5c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez?= Date: Sat, 9 Nov 2024 15:52:35 -0300 Subject: [PATCH 1/2] Add typings to __main__.py --- manim/__main__.py | 57 +++++++++++++++++++++++++++++++++++++---------- mypy.ini | 3 --- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/manim/__main__.py b/manim/__main__.py index f05f4c2971..9807c37f0d 100644 --- a/manim/__main__.py +++ b/manim/__main__.py @@ -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. + 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() @@ -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 diff --git a/mypy.ini b/mypy.ini index 65a77f1d00..afedc5f679 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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 ------------------------ From c0b80d3a32e20f2cad645199e9b9768e3b802336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez=20Novoa?= <49853152+chopan050@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:56:21 -0300 Subject: [PATCH 2/2] Remove `Unused parameter.` from docstrings --- manim/__main__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/manim/__main__.py b/manim/__main__.py index 9807c37f0d..572053bf08 100644 --- a/manim/__main__.py +++ b/manim/__main__.py @@ -21,11 +21,11 @@ def show_splash(ctx: click.Context, param: click.Option, value: str | None) -> N Parameters ---------- ctx - The Click context. Unused parameter. + The Click context. param - A Click option. Unused parameter. + A Click option. value - A string value given by console, or None. Unused parameter. + A string value given by console, or None. """ if value: console.print(f"Manim Community [green]v{__version__}[/green]\n") @@ -40,11 +40,11 @@ def print_version_and_exit( Parameters ---------- ctx - The Click context. Unused parameter. + The Click context. param - A Click option. Unused parameter. + A Click option. value - A string value given by console, or None. Unused parameter. + A string value given by console, or None. """ show_splash(ctx, param, value) if value: