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

Use --py39-plus in pre-commit #3761

Merged
merged 5 commits into from
May 15, 2024
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
hooks:
- id: pyupgrade
name: Update code to new python versions
args: [--py37-plus]
args: [--py39-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down
3 changes: 2 additions & 1 deletion manim/_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

import logging
from collections.abc import Generator
from contextlib import contextmanager
from typing import Any, Generator
from typing import Any

from .cli_colors import parse_cli_ctx
from .logger_utils import make_logger
Expand Down
4 changes: 2 additions & 2 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import os
import re
import sys
from collections.abc import Mapping, MutableMapping
from collections.abc import Iterable, Iterator, Mapping, MutableMapping
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, Iterable, Iterator, NoReturn
from typing import TYPE_CHECKING, Any, ClassVar, NoReturn

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
__all__ = ["Animation", "Wait", "override_animation"]


from collections.abc import Iterable, Sequence
from copy import deepcopy
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Callable

from typing_extensions import Self

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import annotations

import types
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def construct(self):


import itertools as it
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable

import numpy as np

Expand Down
39 changes: 21 additions & 18 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def construct(self):

"""

from __future__ import annotations

__all__ = [
"FocusOn",
"Indicate",
Expand All @@ -37,7 +39,8 @@ def construct(self):
"Blink",
]

from typing import Callable, Iterable, Optional, Tuple, Type, Union
from collections.abc import Iterable
from typing import Callable

import numpy as np

Expand Down Expand Up @@ -93,11 +96,11 @@ def construct(self):

def __init__(
self,
focus_point: Union[np.ndarray, Mobject],
focus_point: np.ndarray | Mobject,
opacity: float = 0.2,
color: str = GREY,
run_time: float = 2,
**kwargs
**kwargs,
) -> None:
self.focus_point = focus_point
self.color = color
Expand Down Expand Up @@ -150,8 +153,8 @@ def __init__(
mobject: Mobject,
scale_factor: float = 1.2,
color: str = YELLOW,
rate_func: Callable[[float, Optional[float]], np.ndarray] = there_and_back,
**kwargs
rate_func: Callable[[float, float | None], np.ndarray] = there_and_back,
**kwargs,
) -> None:
self.color = color
self.scale_factor = scale_factor
Expand Down Expand Up @@ -217,15 +220,15 @@ def construct(self):

def __init__(
self,
point: Union[np.ndarray, Mobject],
point: np.ndarray | Mobject,
line_length: float = 0.2,
num_lines: int = 12,
flash_radius: float = 0.1,
line_stroke_width: int = 3,
color: str = YELLOW,
time_width: float = 1,
run_time: float = 1.0,
**kwargs
**kwargs,
) -> None:
if isinstance(point, Mobject):
self.point = point.get_center()
Expand Down Expand Up @@ -255,7 +258,7 @@ def create_lines(self) -> VGroup:
lines.set_stroke(width=self.line_stroke_width)
return lines

def create_line_anims(self) -> Iterable["ShowPassingFlash"]:
def create_line_anims(self) -> Iterable[ShowPassingFlash]:
return [
ShowPassingFlash(
line,
Expand Down Expand Up @@ -301,11 +304,11 @@ def construct(self):

"""

def __init__(self, mobject: "VMobject", time_width: float = 0.1, **kwargs) -> None:
def __init__(self, mobject: VMobject, time_width: float = 0.1, **kwargs) -> None:
self.time_width = time_width
super().__init__(mobject, remover=True, introducer=True, **kwargs)

def _get_bounds(self, alpha: float) -> Tuple[float]:
def _get_bounds(self, alpha: float) -> tuple[float]:
tw = self.time_width
upper = interpolate(0, 1 + tw, alpha)
lower = upper - tw
Expand Down Expand Up @@ -393,7 +396,7 @@ def __init__(
time_width: float = 1,
ripples: int = 1,
run_time: float = 2,
**kwargs
**kwargs,
) -> None:
x_min = mobject.get_left()[0]
x_max = mobject.get_right()[0]
Expand Down Expand Up @@ -459,7 +462,7 @@ def homotopy(
y: float,
z: float,
t: float,
) -> Tuple[float, float, float]:
) -> tuple[float, float, float]:
upper = interpolate(0, 1 + time_width, t)
lower = upper - time_width
relative_x = inverse_interpolate(x_min, x_max, x)
Expand Down Expand Up @@ -509,10 +512,10 @@ def __init__(
scale_value: float = 1.1,
rotation_angle: float = 0.01 * TAU,
n_wiggles: int = 6,
scale_about_point: Optional[np.ndarray] = None,
rotate_about_point: Optional[np.ndarray] = None,
scale_about_point: np.ndarray | None = None,
rotate_about_point: np.ndarray | None = None,
run_time: float = 2,
**kwargs
**kwargs,
) -> None:
self.scale_value = scale_value
self.rotation_angle = rotation_angle
Expand Down Expand Up @@ -593,15 +596,15 @@ def construct(self):
def __init__(
self,
mobject: Mobject,
shape: Type = Rectangle,
shape: type = Rectangle,
fade_in=False,
fade_out=False,
time_width=0.3,
buff: float = SMALL_BUFF,
color: ParsableManimColor = YELLOW,
run_time=1,
stroke_width=DEFAULT_STROKE_WIDTH,
**kwargs
**kwargs,
):
if shape is Rectangle:
frame = SurroundingRectangle(
Expand Down Expand Up @@ -683,7 +686,7 @@ def __init__(
time_off: float = 0.5,
blinks: int = 1,
hide_at_end: bool = False,
**kwargs
**kwargs,
):
animations = [
UpdateFromFunc(
Expand Down
3 changes: 2 additions & 1 deletion manim/animation/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

__all__ = ["Rotating", "Rotate"]

from typing import TYPE_CHECKING, Callable, Sequence
from collections.abc import Sequence
from typing import TYPE_CHECKING, Callable

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/specialized.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

__all__ = ["Broadcast"]

from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

from manim.animation.transform import Restore

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

import inspect
import types
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Callable

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import itertools as it
import operator as op
import pathlib
from collections.abc import Iterable
from functools import reduce
from typing import Any, Callable, Iterable
from typing import Any, Callable

import cairo
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
]

import itertools as it
from collections.abc import Hashable, Iterable
from copy import copy
from typing import TYPE_CHECKING, Any, Hashable, Iterable, Literal, Protocol, cast
from typing import TYPE_CHECKING, Any, Literal, Protocol, cast

import networkx as nx
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/graphing/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

import fractions as fr
import numbers
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence, TypeVar, overload
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload

import numpy as np
from typing_extensions import Self
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/graphing/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
__all__ = ["ParametricFunction", "FunctionGraph", "ImplicitFunction"]


from typing import TYPE_CHECKING, Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable

import numpy as np
from isosurfaces import plot_isoline
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/graphing/number_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
__all__ = ["NumberLine", "UnitInterval"]


from typing import TYPE_CHECKING, Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
from manim.mobject.geometry.tips import ArrowTip
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/graphing/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ["SampleSpace", "BarChart"]


from typing import Iterable, MutableSequence, Sequence
from collections.abc import Iterable, MutableSequence, Sequence

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/graphing/scale.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import math
from typing import TYPE_CHECKING, Any, Iterable
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def construct(self):


import itertools as it
from typing import Iterable, Sequence
from collections.abc import Iterable, Sequence

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import sys
import types
import warnings
from collections.abc import Iterable
from functools import partialmethod, reduce
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Iterable, Literal
from typing import TYPE_CHECKING, Callable, Literal

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/opengl/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import itertools as it
import random
import sys
from collections.abc import Iterable, Sequence
from functools import partialmethod, wraps
from math import ceil
from typing import Iterable, Sequence

import moderngl
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/opengl/opengl_surface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterable
from pathlib import Path
from typing import Iterable

import moderngl
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/opengl/opengl_vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import itertools as it
import operator as op
from collections.abc import Iterable, Sequence
from functools import reduce, wraps
from typing import Callable, Iterable, Sequence
from typing import Callable

import moderngl
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/svg/brace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ["Brace", "BraceLabel", "ArcBrace", "BraceText", "BraceBetweenPoints"]

from typing import Sequence
from collections.abc import Sequence

import numpy as np
import svgelements as se
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def construct(self):


import itertools as it
from typing import Callable, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import Callable

from manim.mobject.geometry.line import Line
from manim.mobject.geometry.polygram import Polygon
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/text/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ["DecimalNumber", "Integer", "Variable"]

from typing import Sequence
from collections.abc import Sequence

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/text/tex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import itertools as it
import operator as op
import re
from collections.abc import Iterable
from functools import reduce
from textwrap import dedent
from typing import Iterable

from manim import config, logger
from manim.constants import *
Expand Down
Loading
Loading