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 type hints to animation #3457

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
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
5 changes: 3 additions & 2 deletions manim/_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import annotations

import logging
from contextlib import _GeneratorContextManager, contextmanager
from contextlib import contextmanager
from typing import Any, Generator

from .cli_colors import parse_cli_ctx
from .logger_utils import make_logger
Expand Down Expand Up @@ -40,7 +41,7 @@

# This has to go here because it needs access to this module's config
@contextmanager
def tempconfig(temp: ManimConfig | dict) -> _GeneratorContextManager:
def tempconfig(temp: ManimConfig | dict[str, Any]) -> Generator[None, None, None]:
"""Context manager that temporarily modifies the global ``config`` object.

Inside the ``with`` statement, the modified config will be used. After
Expand Down
9 changes: 4 additions & 5 deletions manim/_config/logger_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def make_logger(
parser: configparser.ConfigParser,
verbosity: str,
) -> tuple[logging.Logger, Console]:
) -> tuple[logging.Logger, Console, Console]:
"""Make the manim logger and console.

Parameters
Expand Down Expand Up @@ -84,14 +84,13 @@ def make_logger(
theme = parse_theme(parser)
console = Console(theme=theme)

# With rich 9.5.0+ we could pass stderr=True instead
error_console = Console(theme=theme, file=sys.stderr)
error_console = Console(theme=theme, stderr=True)

# set the rich handler
RichHandler.KEYWORDS = HIGHLIGHTED_KEYWORDS
rich_handler = RichHandler(
console=console,
show_time=parser.getboolean("log_timestamps"),
keywords=HIGHLIGHTED_KEYWORDS,
)

# finally, the logger
Expand Down Expand Up @@ -178,7 +177,7 @@ class JSONFormatter(logging.Formatter):

"""

def format(self, record: dict) -> str:
def format(self, record: logging.LogRecord) -> str:
"""Format the record in a custom JSON format."""
record_c = copy.deepcopy(record)
if record_c.args:
Expand Down
Loading
Loading