Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
54 changes: 12 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,20 @@ repos:
- id: end-of-file-fixer
- id: check-toml
name: Validate Poetry
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
name: Update code to new python versions
args: [--py39-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
name: Precision flake ignores
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==24.4.0]
exclude: ^\.github/
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
[
flake8-bugbear==21.4.3,
flake8-builtins==1.5.3,
flake8-comprehensions>=3.6.1,
flake8-docstrings==1.6.0,
flake8-pytest-style==1.5.0,
flake8-rst-docstrings==0.2.3,
flake8-simplify==0.14.1,
]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff
args: [ "--fix", "--exit-non-zero-on-fix"]
name: ruff lint
types: [python]
- id: ruff-format
types: [python]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
Expand All @@ -77,4 +45,6 @@ repos:
hooks:
- id: codespell
files: ^.*\.(py|md|rst)$
args: ["-L", "medias,nam"]
# for pyproject configuration (remove python>=3.11)
additional_dependencies:
- tomli
9 changes: 4 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

from __future__ import annotations

try:
# https://github.com/moderngl/moderngl/issues/517
import readline # required to prevent a segfault on Python 3.10
except ModuleNotFoundError: # windows
pass
import contextlib

with contextlib.suppress(ModuleNotFoundError):
import readline # noqa: F401

import cairo
import moderngl
Expand Down
1 change: 1 addition & 0 deletions docs/rtd-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jupyterlab
sphinxcontrib-programoutput
pytest
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# -- Project information -----------------------------------------------------

project = "Manim"
copyright = f"2020-{datetime.now().year}, The Manim Community Dev Team"
copyright = f"2020-{datetime.now().year}, The Manim Community Dev Team" # noqa: A001
author = "The Manim Community Dev Team"


Expand Down Expand Up @@ -63,7 +63,7 @@
alias_name: f"~manim.{module}.{alias_name}"
for module, module_dict in ALIAS_DOCS_DICT.items()
for category_dict in module_dict.values()
for alias_name in category_dict.keys()
for alias_name in category_dict
}
autoclass_content = "both"

Expand Down
2 changes: 2 additions & 0 deletions example_scenes/advanced_tex_fonts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from manim import *

# French Cursive LaTeX font example from http://jf.burnol.free.fr/showcase.html
Expand Down
4 changes: 2 additions & 2 deletions example_scenes/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python

from __future__ import annotations

from manim import *

Expand Down Expand Up @@ -153,7 +153,7 @@ def construct(self):
],
color=PURPLE_B,
fill_opacity=1,
stroke_width=0
stroke_width=0,
).shift(UP + 2 * RIGHT)
shapes = VGroup(triangle, square, circle, pentagon, pi)
self.play(SpiralIn(shapes, fade_in_fraction=0.9))
Expand Down
2 changes: 2 additions & 0 deletions example_scenes/customtex.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from manim import *


Expand Down
6 changes: 4 additions & 2 deletions example_scenes/opengl.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

from pathlib import Path

import manim.utils.opengl as opengl
from manim import *
from manim.opengl import * # type: ignore
from manim.opengl import *
from manim.utils import opengl

# Copied from https://3b1b.github.io/manim/getting_started/example_scenes.html#surfaceexample.
# Lines that do not yet work with the Community Version are commented.
Expand Down
1 change: 1 addition & 0 deletions manim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
__version__ = version(__name__)


# ruff: noqa: F401
# isort: off

# Importing the config module should be the first thing we do, since other
Expand Down
1 change: 0 additions & 1 deletion manim/_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def tempconfig(temp: ManimConfig | dict[str, Any]) -> Generator[None, None, None
8.0
>>> with tempconfig({"frame_height": 100.0}):
... print(config["frame_height"])
...
100.0
>>> config["frame_height"]
8.0
Expand Down
9 changes: 6 additions & 3 deletions manim/_config/cli_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ def parse_cli_ctx(parser: configparser.SectionProxy) -> Context:
theme = parser["theme"] if parser["theme"] else None
if theme is None:
formatter = HelpFormatter.settings(
theme=HelpTheme(**theme_settings), **formatter_settings # type: ignore[arg-type]
theme=HelpTheme(**theme_settings),
**formatter_settings, # type: ignore[arg-type]
)
elif theme.lower() == "dark":
formatter = HelpFormatter.settings(
theme=HelpTheme.dark().with_(**theme_settings), **formatter_settings # type: ignore[arg-type]
theme=HelpTheme.dark().with_(**theme_settings),
**formatter_settings, # type: ignore[arg-type]
)
elif theme.lower() == "light":
formatter = HelpFormatter.settings(
theme=HelpTheme.light().with_(**theme_settings), **formatter_settings # type: ignore[arg-type]
theme=HelpTheme.light().with_(**theme_settings),
**formatter_settings, # type: ignore[arg-type]
)

return Context.settings(
Expand Down
17 changes: 7 additions & 10 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,14 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:
gui_location = tuple(
map(int, re.split(r"[;,\-]", parser["CLI"]["gui_location"])),
)
setattr(self, "gui_location", gui_location)
self.gui_location = gui_location

window_size = parser["CLI"][
"window_size"
] # if not "default", get a tuple of the position
if window_size != "default":
window_size = tuple(map(int, re.split(r"[;,\-]", window_size)))
setattr(self, "window_size", window_size)
self.window_size = window_size

# plugins
plugins = parser["CLI"].get("plugins", fallback="", raw=True)
Expand All @@ -672,7 +672,7 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:

val = parser["CLI"].get("progress_bar")
if val:
setattr(self, "progress_bar", val)
self.progress_bar = val

val = parser["ffmpeg"].get("loglevel")
if val:
Expand All @@ -682,11 +682,11 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:
val = parser["jupyter"].getboolean("media_embed")
except ValueError:
val = None
setattr(self, "media_embed", val)
self.media_embed = val

val = parser["jupyter"].get("media_width")
if val:
setattr(self, "media_width", val)
self.media_width = val

val = parser["CLI"].get("quality", fallback="", raw=True)
if val:
Expand Down Expand Up @@ -837,15 +837,12 @@ def digest_args(self, args: argparse.Namespace) -> Self:
if args.tex_template:
self.tex_template = TexTemplate.from_file(args.tex_template)

if (
self.renderer == RendererType.OPENGL
and getattr(args, "write_to_movie") is None
):
if self.renderer == RendererType.OPENGL and args.write_to_movie is None:
# --write_to_movie was not passed on the command line, so don't generate video.
self["write_to_movie"] = False

# Handle --gui_location flag.
if getattr(args, "gui_location") is not None:
if args.gui_location is not None:
self.gui_location = args.gui_location

return self
Expand Down
2 changes: 1 addition & 1 deletion manim/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _typecheck_input(self, mobject: Mobject | None) -> None:
def __str__(self) -> str:
if self.name:
return self.name
return f"{self.__class__.__name__}({str(self.mobject)})"
return f"{self.__class__.__name__}({self.mobject!s})"

def __repr__(self) -> str:
return str(self)
Expand Down
4 changes: 3 additions & 1 deletion manim/animation/changing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ def construct(self):
def __init__(
self,
vmobject,
colors=[BLUE_D, BLUE_B, BLUE_E, GREY_BROWN],
colors=None,
max_stroke_width=3,
cycle_rate=0.5,
back_and_forth=True,
draw_rate_func=smooth,
fade_rate_func=smooth,
**kwargs,
):
if colors is None:
colors = [BLUE_D, BLUE_B, BLUE_E, GREY_BROWN]
super().__init__(**kwargs)
self.colors = colors
self.max_stroke_width = max_stroke_width
Expand Down
8 changes: 6 additions & 2 deletions manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,15 @@ def __init__(
rate_func: Callable[[float], float] = double_smooth,
stroke_width: float = 2,
stroke_color: str = None,
draw_border_animation_config: dict = {}, # what does this dict accept?
fill_animation_config: dict = {},
draw_border_animation_config: dict = None, # what does this dict accept?
fill_animation_config: dict = None,
introducer: bool = True,
**kwargs,
) -> None:
if fill_animation_config is None:
fill_animation_config = {}
if draw_border_animation_config is None:
draw_border_animation_config = {}
self._typecheck_input(vmobject)
super().__init__(
vmobject,
Expand Down
1 change: 0 additions & 1 deletion manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def construct(self):
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..utils.bezier import interpolate, inverse_interpolate
from ..utils.color import GREY, YELLOW, ParsableManimColor
from ..utils.deprecation import deprecated
from ..utils.rate_functions import smooth, there_and_back, wiggle
from ..utils.space_ops import normalize

Expand Down
9 changes: 4 additions & 5 deletions manim/cli/cfg/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import contextlib
from ast import literal_eval
from pathlib import Path

Expand Down Expand Up @@ -51,10 +52,8 @@ def value_from_string(value: str) -> str | int | bool:
Union[:class:`str`, :class:`int`, :class:`bool`]
Returns the literal of appropriate datatype.
"""
try:
with contextlib.suppress(SyntaxError, ValueError):
value = literal_eval(value)
except (SyntaxError, ValueError):
pass
return value


Expand Down Expand Up @@ -192,12 +191,12 @@ def write(level: str = None, openfile: bool = False) -> None:
console.print(f"(defaults to {defaultval}) :", end="")
try:
temp = input()
except EOFError:
except EOFError as eof:
raise Exception(
"""Not enough values in input.
You may have added a new entry to default.cfg, in which case you will have to
modify write_cfg_subcmd_input to account for it.""",
)
) from eof
if temp:
while temp and not _is_expected_datatype(
temp,
Expand Down
3 changes: 0 additions & 3 deletions manim/cli/checkhealth/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

import os
import shutil
import subprocess
from typing import Callable

from ..._config import config

__all__ = ["HEALTH_CHECKS"]

HEALTH_CHECKS = []
Expand Down
3 changes: 3 additions & 0 deletions manim/cli/default_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
of ``click.Group``.
"""

from __future__ import annotations

import warnings

import cloup
Expand Down Expand Up @@ -65,6 +67,7 @@ def command(self, *args, **kwargs):
warnings.warn(
"Use default param of DefaultGroup or set_default_command() instead",
DeprecationWarning,
stacklevel=2,
)

def _decorator(f):
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/init/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def select_resolution():
show_default=False,
default="480p",
)
return [res for res in resolution_options if f"{res[0]}p" == choice][0]
return next(res for res in resolution_options if f"{res[0]}p" == choice)


def update_cfg(cfg_dict: dict, project_cfg_path: Path):
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/render/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@cloup.argument("scene_names", required=False, nargs=-1)
@global_options
@output_options
@render_options # type: ignore
@render_options
@ease_of_access_options
def render(
**args,
Expand Down
3 changes: 2 additions & 1 deletion manim/cli/render/global_options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import re
import sys

from cloup import Choice, option, option_group

Expand All @@ -16,7 +17,7 @@ def validate_gui_location(ctx, param, value):
return (x_offset, y_offset)
except Exception:
logger.error("GUI location option is invalid.")
exit()
sys.exit()


global_options = option_group(
Expand Down
Loading