diff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.py index 7405d62e69..cf50aa9b9c 100644 --- a/manim/utils/ipython_magic.py +++ b/manim/utils/ipython_magic.py @@ -5,6 +5,7 @@ import shutil from datetime import datetime from pathlib import Path +from typing import Any, Dict, List from manim import Group, config, logger, tempconfig from manim.__main__ import main @@ -12,6 +13,7 @@ try: from IPython import get_ipython + from IPython.core.interactiveshell import InteractiveShell from IPython.core.magic import ( Magics, line_cell_magic, @@ -25,13 +27,18 @@ @magics_class class ManimMagic(Magics): - def __init__(self, shell): + def __init__(self, shell: InteractiveShell) -> None: super().__init__(shell) self.rendered_files = {} @needs_local_scope @line_cell_magic - def manim(self, line, cell=None, local_ns=None): + def manim( + self, + line: str, + cell: str = None, + local_ns: Dict[str, Any] = None, + ) -> None: r"""Render Manim scenes contained in IPython cells. Works as a line or cell magic. @@ -169,7 +176,7 @@ def construct(self): ), ) - def add_additional_args(self, args): + def add_additional_args(self, args: List[str]) -> List[str]: additional_args = ["--jupyter"] # Use webm to support transparency if "-t" in args and "--format" not in args: @@ -177,5 +184,5 @@ def add_additional_args(self, args): return additional_args + args[:-1] + [""] + [args[-1]] -def _generate_file_name(): +def _generate_file_name() -> str: return config["scene_names"][0] + "@" + datetime.now().strftime("%Y-%m-%d@%H-%M-%S")