From 7a77ee68cf2829d4abcf728362541729eaa69d30 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Thu, 20 Jan 2022 17:22:59 +0100 Subject: [PATCH] Replace string annotation with new typehints --- manim/animation/animation.py | 4 ++-- manim/mobject/graph.py | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manim/animation/animation.py b/manim/animation/animation.py index ece0ae70f5..c597a0bdc0 100644 --- a/manim/animation/animation.py +++ b/manim/animation/animation.py @@ -147,7 +147,7 @@ def __init__( self.introducer: bool = introducer self.suspend_mobject_updating: bool = suspend_mobject_updating self.lag_ratio: float = lag_ratio - self._on_finish: Callable[["Scene"], None] = _on_finish + self._on_finish: Callable[[Scene], None] = _on_finish if config["renderer"] == "opengl": self.starting_mobject: OpenGLMobject = OpenGLMobject() self.mobject: OpenGLMobject = ( @@ -228,7 +228,7 @@ def clean_up_from_scene(self, scene: Scene) -> None: if self.is_remover(): scene.remove(self.mobject) - def _setup_scene(self, scene: "Scene") -> None: + def _setup_scene(self, scene: Scene) -> None: """Setup up the :class:`~.Scene` before starting the animation. This includes to :meth:`~.Scene.add` the Animation's diff --git a/manim/mobject/graph.py b/manim/mobject/graph.py index e0079b62b2..379a4db1de 100644 --- a/manim/mobject/graph.py +++ b/manim/mobject/graph.py @@ -502,13 +502,13 @@ def __repr__(self: Graph) -> str: def _create_vertex( self, vertex: Hashable, - position: Optional[np.ndarray] = None, + position: np.ndarray | None = None, label: bool = False, label_fill_color: str = BLACK, - vertex_type: Type["Mobject"] = Dot, - vertex_config: Optional[dict] = None, - vertex_mobject: Optional[dict] = None, - ) -> Tuple[Hashable, np.ndarray, dict, "Mobject"]: + vertex_type: type[Mobject] = Dot, + vertex_config: dict | None = None, + vertex_mobject: dict | None = None, + ) -> tuple[Hashable, np.ndarray, dict, Mobject]: if position is None: position = self.get_center() @@ -550,8 +550,8 @@ def _add_created_vertex( vertex: Hashable, position: np.ndarray, vertex_config: dict, - vertex_mobject: "Mobject", - ) -> "Mobject": + vertex_mobject: Mobject, + ) -> Mobject: if vertex in self.vertices: raise ValueError( f"Vertex identifier '{vertex}' is already used for a vertex in this graph.", @@ -621,15 +621,15 @@ def _add_vertex( ) def _create_vertices( - self: "Graph", + self: Graph, *vertices: Hashable, - positions: Optional[dict] = None, + positions: dict | None = None, labels: bool = False, label_fill_color: str = BLACK, - vertex_type: Type["Mobject"] = Dot, - vertex_config: Optional[dict] = None, - vertex_mobjects: Optional[dict] = None, - ) -> Iterable[Tuple[Hashable, np.ndarray, dict, "Mobject"]]: + vertex_type: type[Mobject] = Dot, + vertex_config: dict | None = None, + vertex_mobjects: dict | None = None, + ) -> Iterable[tuple[Hashable, np.ndarray, dict, Mobject]]: if positions is None: positions = {} if vertex_mobjects is None: @@ -734,7 +734,7 @@ def _add_vertices_animation(self, *args, anim_args=None, **kwargs): vertex_mobjects = self._create_vertices(*args, **kwargs) - def on_finish(scene: "Scene"): + def on_finish(scene: Scene): for v in vertex_mobjects: scene.remove(v[-1]) self._add_created_vertex(*v)