mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Report invalid configuration value upon manager initialization
Also fixes the variance of Manager[T]
This commit is contained in:
parent
45aef8e556
commit
9e07cbad72
1 changed files with 7 additions and 8 deletions
|
|
@ -29,7 +29,7 @@ from manim.utils.progressbar import (
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing import Any, Self
|
||||
|
||||
import numpy.typing as npt
|
||||
|
||||
|
|
@ -37,10 +37,10 @@ if TYPE_CHECKING:
|
|||
from manim.file_writer.protocols import FileWriterProtocol
|
||||
from manim.renderer.renderer import RendererProtocol
|
||||
|
||||
Scene_co = TypeVar("Scene_co", covariant=True, bound=Scene)
|
||||
SceneT = TypeVar("SceneT", bound=Scene)
|
||||
|
||||
|
||||
class Manager(Generic[Scene_co]):
|
||||
class Manager(Generic[SceneT]):
|
||||
"""
|
||||
The Brain of Manim
|
||||
|
||||
|
|
@ -66,9 +66,9 @@ class Manager(Generic[Scene_co]):
|
|||
manager.render()
|
||||
"""
|
||||
|
||||
def __init__(self, scene_cls: type[Scene_co]) -> None:
|
||||
# scene
|
||||
self.scene: Scene_co = scene_cls(manager=self)
|
||||
def __init__(self, scene_cls: type[SceneT]) -> None:
|
||||
config._warn_about_config_options()
|
||||
self.scene: SceneT = scene_cls(manager=self)
|
||||
|
||||
if not isinstance(self.scene, Scene):
|
||||
raise ValueError(f"{self.scene!r} is not an instance of Scene")
|
||||
|
|
@ -90,7 +90,7 @@ class Manager(Generic[Scene_co]):
|
|||
def __str__(self) -> str:
|
||||
return f"{self.__class__.__name__}({self.scene!r}) at time {self.time:.2f}s"
|
||||
|
||||
def __enter__(self) -> Manager[Scene_co]:
|
||||
def __enter__(self) -> Self:
|
||||
return self
|
||||
|
||||
def __exit__(
|
||||
|
|
@ -170,7 +170,6 @@ class Manager(Generic[Scene_co]):
|
|||
with tempconfig({"preview": True}), Manager(MyScene) as manager:
|
||||
manager.render()
|
||||
"""
|
||||
config._warn_about_config_options()
|
||||
self._render_first_pass()
|
||||
self._render_second_pass()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue