Skip to content
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
Prev Previous commit
Next Next commit
run linter
  • Loading branch information
jeertmans committed Oct 18, 2023
commit 288869203d20ea03230a6c7e6af51c11281d7627
1 change: 0 additions & 1 deletion manim_slides/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# flake8: noqa: F401
import sys
from types import ModuleType
from typing import Any, List
Expand Down
2 changes: 1 addition & 1 deletion manim_slides/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class PresentationConfig(BaseModel): # type: ignore[misc]
@classmethod
def from_file(cls, path: Path) -> "PresentationConfig":
"""Reads a presentation configuration from a file."""
with open(path, "r") as f:
with open(path) as f:
obj = json.load(f)

slides = obj.setdefault("slides", [])
Expand Down
9 changes: 5 additions & 4 deletions manim_slides/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,10 @@ def open(self, file: Path) -> bool:
return webbrowser.open(file.absolute().as_uri())

def convert_to(self, dest: Path) -> None:
"""Converts this configuration into a RevealJS HTML presentation, saved to
DEST."""
"""
Converts this configuration into a RevealJS HTML presentation, saved to
DEST.
"""
if self.data_uri:
assets_dir = Path("") # Actually we won't care.
else:
Expand Down Expand Up @@ -547,7 +549,7 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
presentation_configs=[PresentationConfig()]
)
for key, value in converter.dict().items():
click.echo(f"{key}: {repr(value)}")
click.echo(f"{key}: {value!r}")

ctx.exit()

Expand Down Expand Up @@ -637,7 +639,6 @@ def convert(
template: Optional[Path],
) -> None:
"""Convert SCENE(s) into a given format and writes the result in DEST."""

presentation_configs = get_scenes_presentation_config(scenes, folder)

try:
Expand Down
6 changes: 3 additions & 3 deletions manim_slides/docs/manim_slides_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def construct(self):
A list of methods, separated by spaces,
that is rendered in a reference block after the source code.

"""
""" # noqa: D400, D415
from __future__ import annotations

import csv
Expand All @@ -123,7 +123,6 @@ def construct(self):
import sys
from pathlib import Path
from timeit import timeit
from typing import Tuple

import jinja2
from docutils import nodes
Expand Down Expand Up @@ -182,6 +181,7 @@ class ManimSlidesDirective(Directive):

See the module docstring for documentation.
"""

has_content = True
required_arguments = 1
optional_arguments = 0
Expand Down Expand Up @@ -227,7 +227,7 @@ def run(self): # noqa: C901

global classnamedict

def split_file_cls(arg: str) -> Tuple[Path, str]:
def split_file_cls(arg: str) -> tuple[Path, str]:
if ":" in arg:
file, cls = arg.split(":", maxsplit=1)
_, file = self.state.document.settings.env.relfn2path(file)
Expand Down
13 changes: 7 additions & 6 deletions manim_slides/ipython/ipython_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Note that you will still need to install Manim's platform-specific dependencies,
see
`their installation page <https://docs.manim.community/en/stable/installation.html>`_.
"""
""" # noqa: D400, D415

from __future__ import annotations

Expand All @@ -30,7 +30,7 @@
import shutil
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, Optional
from typing import Any

from IPython import get_ipython
from IPython.core.interactiveshell import InteractiveShell
Expand All @@ -49,15 +49,15 @@
class ManimSlidesMagic(Magics): # type: ignore
def __init__(self, shell: InteractiveShell) -> None:
super().__init__(shell)
self.rendered_files: Dict[Path, Path] = {}
self.rendered_files: dict[Path, Path] = {}

@needs_local_scope
@line_cell_magic
def manim_slides( # noqa: C901
self,
line: str,
cell: Optional[str] = None,
local_ns: Dict[str, Any] = {},
cell: str | None = None,
local_ns: dict[str, Any] | None = None,
) -> None:
r"""
Render Manim Slides contained in IPython cells. Works as a line or cell magic.
Expand Down Expand Up @@ -118,7 +118,6 @@ def construct(self):

Examples
--------

First make sure to put ``from manim_slides import ManimSlidesMagic``,
or even ``from manim_slides import *``
in a cell and evaluate it. Then, a typical Jupyter notebook cell for Manim Slides
Expand All @@ -144,6 +143,8 @@ def construct(self):
option should be set to ``None``. This can also be done by passing ``--progress_bar None`` as a
CLI flag.
"""
if local_ns is None:
local_ns = {}
if cell:
exec(cell, local_ns)

Expand Down
3 changes: 0 additions & 3 deletions manim_slides/present/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@verbosity_option
def list_scenes(folder: Path) -> None:
"""List available scenes."""

for i, scene in enumerate(_list_scenes(folder), start=1):
click.secho(f"{i}: {scene}", fg="green")

Expand All @@ -53,7 +52,6 @@ def _list_scenes(folder: Path) -> List[str]:

def prompt_for_scenes(folder: Path) -> List[str]:
"""Prompts the user to select scenes within a given folder."""

scene_choices = dict(enumerate(_list_scenes(folder), start=1))

for i, scene in scene_choices.items():
Expand Down Expand Up @@ -242,7 +240,6 @@ def present(
Use ``manim-slide list-scenes`` to list all available
scenes in a given folder.
"""

if skip_all:
exit_after_last_slide = True

Expand Down
2 changes: 1 addition & 1 deletion manim_slides/present/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ..config import Config, PresentationConfig, SlideConfig
from ..logger import logger
from ..resources import * # noqa: F401, F403
from ..resources import * # noqa: F403

WINDOW_NAME = "Manim Slides"

Expand Down
2 changes: 0 additions & 2 deletions manim_slides/slide/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class Wipe(AnimationGroup): # type: ignore[misc]

Examples
--------

.. manim-slides:: WipeClassExample

from manim import *
Expand Down Expand Up @@ -99,7 +98,6 @@ class Zoom(AnimationGroup): # type: ignore[misc]

Examples
--------

.. manim-slides:: ZoomClassExample

from manim import *
Expand Down
13 changes: 4 additions & 9 deletions manim_slides/slide/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def canvas(self) -> MutableMapping[str, Mobject]:

Examples
--------

.. manim-slides:: CanvasExample

from manim import *
Expand Down Expand Up @@ -179,8 +178,10 @@ def canvas_mobjects(self) -> ValuesView[Mobject]:

@property
def mobjects_without_canvas(self) -> Sequence[Mobject]:
"""Returns the list of objects contained in the scene, minus those present in
the canvas."""
"""
Returns the list of objects contained in the scene, minus those present in
the canvas.
"""
return [
mobject for mobject in self.mobjects if mobject not in self.canvas_mobjects # type: ignore[attr-defined]
]
Expand All @@ -203,7 +204,6 @@ def wait_time_between_slides(self) -> float:

Examples
--------

.. manim-slides:: WithoutWaitExample

from manim import *
Expand Down Expand Up @@ -269,7 +269,6 @@ def next_slide(self) -> None:

Examples
--------

The following contains 3 slides:

#. the first with nothing on it;
Expand Down Expand Up @@ -308,7 +307,6 @@ def construct(self):

def _add_last_slide(self) -> None:
"""Adds a 'last' slide to the end of slides."""

if (
len(self._slides) > 0
and self._current_animation == self._slides[-1].end_animation
Expand Down Expand Up @@ -342,7 +340,6 @@ def start_loop(self) -> None:

Examples
--------

The following contains one slide that will loop endlessly.

.. manim-slides:: LoopExample
Expand Down Expand Up @@ -477,7 +474,6 @@ def wipe(

Examples
--------

.. manim-slides:: WipeExample

from manim import *
Expand Down Expand Up @@ -533,7 +529,6 @@ def zoom(

Examples
--------

.. manim-slides:: ZoomExample

from manim import *
Expand Down
7 changes: 4 additions & 3 deletions manim_slides/slide/manim.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@


class Slide(BaseSlide, Scene): # type: ignore[misc]
"""Inherits from :class:`Scene<manim.scene.scene.Scene>` and provide necessary tools
for slides rendering."""
"""
Inherits from :class:`Scene<manim.scene.scene.Scene>` and provide necessary tools
for slides rendering.
"""

@property
def _ffmpeg_bin(self) -> Path:
Expand Down Expand Up @@ -83,7 +85,6 @@ class ThreeDSlide(Slide, ThreeDScene): # type: ignore[misc]

Examples
--------

.. manim-slides:: ThreeDExample

from manim import *
Expand Down
1 change: 0 additions & 1 deletion manim_slides/slide/manimlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def _resolution(self) -> Tuple[int, int]:
@property
def _partial_movie_files(self) -> List[Path]:
"""Returns a list of partial movie files, a.k.a animations."""

kwargs = {
"remove_non_integer_files": True,
"extension": self.file_writer.movie_file_extension,
Expand Down
1 change: 0 additions & 1 deletion manim_slides/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

def concatenate_video_files(ffmpeg_bin: Path, files: List[Path], dest: Path) -> None:
"""Concatenate multiple video files into one."""

f = tempfile.NamedTemporaryFile(mode="w", delete=False)
f.writelines(f"file '{path.absolute()}'\n" for path in files)
f.close()
Expand Down
9 changes: 5 additions & 4 deletions manim_slides/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .config import Config, Key
from .defaults import CONFIG_PATH
from .logger import logger
from .resources import * # noqa: F401, F403
from .resources import * # noqa: F403

WINDOW_NAME: str = "Configuration Wizard"

Expand Down Expand Up @@ -149,9 +149,10 @@ def init(
def _init(
config_path: Path, force: bool, merge: bool, skip_interactive: bool = False
) -> None:
"""Actual initialization code for configuration file, with optional interactive
mode."""

"""
Actual initialization code for configuration file, with optional interactive
mode.
"""
if config_path.exists():
click.secho(f"The `{CONFIG_PATH}` configuration file exists")

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ filterwarnings = [
[tool.ruff]
extend-select = ["B", "C90", "D", "I", "N", "RUF", "UP", "T"]
ignore = [
"D203",
"D205",
"D212",
"E501"
]
isort = {known-first-party = ['manim_slides', 'tests']}
line-length = 88
target-version = "py38"
2 changes: 1 addition & 1 deletion tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_format_enum(enum_type: EnumMeta) -> None:

assert expected == got

got = "{enum}".format(enum=enum)
got = "{enum}".format(enum=enum) # noqa: UP032

assert expected == got

Expand Down