Skip to content

Commit 3a4ab4c

Browse files
Rename parameters and variables conflicting with builtin functions (#3884)
* Config for flake8-builtins * Manual changes for flake8-builtins
1 parent d6dac76 commit 3a4ab4c

File tree

13 files changed

+46
-44
lines changed

13 files changed

+46
-44
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ repos:
3232
- id: flake8
3333
additional_dependencies:
3434
[
35-
flake8-builtins==1.5.3,
3635
flake8-docstrings==1.6.0,
3736
flake8-pytest-style==1.5.0,
3837
flake8-rst-docstrings==0.2.3,

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# -- Project information -----------------------------------------------------
2727

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

3232

manim/mobject/mobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,10 +2484,10 @@ def init_size(num, alignments, sizes):
24842484
buff_x = buff_y = buff
24852485

24862486
# Initialize alignments correctly
2487-
def init_alignments(alignments, num, mapping, name, dir):
2487+
def init_alignments(alignments, num, mapping, name, dir_):
24882488
if alignments is None:
24892489
# Use cell_alignment as fallback
2490-
return [cell_alignment * dir] * num
2490+
return [cell_alignment * dir_] * num
24912491
if len(alignments) != num:
24922492
raise ValueError(f"{name}_alignments has a mismatching size.")
24932493
alignments = list(alignments)

manim/mobject/svg/svg_mobject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def get_mobjects_from(self, svg: se.SVG) -> list[VMobject]:
264264
"""
265265
result = []
266266
for shape in svg.elements():
267-
if isinstance(shape, se.Group):
267+
# can we combine the two continue cases into one?
268+
if isinstance(shape, se.Group): # noqa: SIM114
268269
continue
269270
elif isinstance(shape, se.Path):
270271
mob = self.path_to_mobject(shape)

manim/renderer/opengl_renderer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ def __init__(
6363
if self.orthographic:
6464
self.projection_matrix = opengl.orthographic_projection_matrix()
6565
self.unformatted_projection_matrix = opengl.orthographic_projection_matrix(
66-
format=False,
66+
format_=False,
6767
)
6868
else:
6969
self.projection_matrix = opengl.perspective_projection_matrix()
7070
self.unformatted_projection_matrix = opengl.perspective_projection_matrix(
71-
format=False,
71+
format_=False,
7272
)
7373

7474
if frame_shape is None:

manim/scene/scene.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,14 @@ def construct(self):
308308
def next_section(
309309
self,
310310
name: str = "unnamed",
311-
type: str = DefaultSectionType.NORMAL,
311+
section_type: str = DefaultSectionType.NORMAL,
312312
skip_animations: bool = False,
313313
) -> None:
314314
"""Create separation here; the last section gets finished and a new one gets created.
315315
``skip_animations`` skips the rendering of all animations in this section.
316316
Refer to :doc:`the documentation</tutorials/output_and_config>` on how to use sections.
317317
"""
318-
self.renderer.file_writer.next_section(name, type, skip_animations)
318+
self.renderer.file_writer.next_section(name, section_type, skip_animations)
319319

320320
def __str__(self):
321321
return self.__class__.__name__

manim/scene/scene_file_writer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, renderer, scene_name, **kwargs):
7878
# first section gets automatically created for convenience
7979
# if you need the first section to be skipped, add a first section by hand, it will replace this one
8080
self.next_section(
81-
name="autocreated", type=DefaultSectionType.NORMAL, skip_animations=False
81+
name="autocreated", type_=DefaultSectionType.NORMAL, skip_animations=False
8282
)
8383

8484
def init_output_directories(self, scene_name):
@@ -163,7 +163,7 @@ def finish_last_section(self) -> None:
163163
if len(self.sections) and self.sections[-1].is_empty():
164164
self.sections.pop()
165165

166-
def next_section(self, name: str, type: str, skip_animations: bool) -> None:
166+
def next_section(self, name: str, type_: str, skip_animations: bool) -> None:
167167
"""Create segmentation cut here."""
168168
self.finish_last_section()
169169

@@ -181,7 +181,7 @@ def next_section(self, name: str, type: str, skip_animations: bool) -> None:
181181

182182
self.sections.append(
183183
Section(
184-
type,
184+
type_,
185185
section_video,
186186
name,
187187
skip_animations,

manim/scene/section.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ class PresentationSectionType(str, Enum):
3434

3535

3636
class Section:
37-
"""A :class:`.Scene` can be segmented into multiple Sections.
37+
r"""A :class:`.Scene` can be segmented into multiple Sections.
3838
Refer to :doc:`the documentation</tutorials/output_and_config>` for more info.
3939
It consists of multiple animations.
4040
4141
Attributes
4242
----------
43-
type
44-
Can be used by a third party applications to classify different types of sections.
45-
video
46-
Path to video file with animations belonging to section relative to sections directory.
47-
If ``None``, then the section will not be saved.
48-
name
49-
Human readable, non-unique name for this section.
50-
skip_animations
51-
Skip rendering the animations in this section when ``True``.
52-
partial_movie_files
53-
Animations belonging to this section.
43+
type\_
44+
Can be used by a third party applications to classify different types of sections.
45+
video
46+
Path to video file with animations belonging to section relative to sections directory.
47+
If ``None``, then the section will not be saved.
48+
name
49+
Human readable, non-unique name for this section.
50+
skip_animations
51+
Skip rendering the animations in this section when ``True``.
52+
partial_movie_files
53+
Animations belonging to this section.
5454
5555
See Also
5656
--------
@@ -59,8 +59,8 @@ class Section:
5959
:meth:`.OpenGLRenderer.update_skipping_status`
6060
"""
6161

62-
def __init__(self, type: str, video: str | None, name: str, skip_animations: bool):
63-
self.type = type
62+
def __init__(self, type_: str, video: str | None, name: str, skip_animations: bool):
63+
self.type_ = type_
6464
# None when not to be saved -> still keeps section alive
6565
self.video: str | None = video
6666
self.name = name
@@ -94,7 +94,7 @@ def get_dict(self, sections_dir: Path) -> dict[str, Any]:
9494
return dict(
9595
{
9696
"name": self.name,
97-
"type": self.type,
97+
"type": self.type_,
9898
"video": self.video,
9999
},
100100
**video_metadata,

manim/utils/color/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _internal_from_integer(value: int, alpha: float) -> ManimColorInternal:
217217

218218
# TODO: Maybe make 8 nibble hex also convertible ?
219219
@staticmethod
220-
def _internal_from_hex_string(hex: str, alpha: float) -> ManimColorInternal:
220+
def _internal_from_hex_string(hex_: str, alpha: float) -> ManimColorInternal:
221221
"""Internal function for converting a hex string into the internal representation of a ManimColor.
222222
223223
.. warning::
@@ -238,9 +238,9 @@ def _internal_from_hex_string(hex: str, alpha: float) -> ManimColorInternal:
238238
ManimColorInternal
239239
Internal color representation
240240
"""
241-
if len(hex) == 6:
242-
hex += "00"
243-
tmp = int(hex, 16)
241+
if len(hex_) == 6:
242+
hex_ += "00"
243+
tmp = int(hex_, 16)
244244
return np.asarray(
245245
(
246246
((tmp >> 24) & 0xFF) / 255,
@@ -590,12 +590,12 @@ def from_rgba(
590590
return cls(rgba)
591591

592592
@classmethod
593-
def from_hex(cls, hex: str, alpha: float = 1.0) -> Self:
593+
def from_hex(cls, hex_str: str, alpha: float = 1.0) -> Self:
594594
"""Creates a Manim Color from a hex string, prefixes allowed # and 0x
595595
596596
Parameters
597597
----------
598-
hex : str
598+
hex_str : str
599599
The hex string to be converted (currently only supports 6 nibbles)
600600
alpha : float, optional
601601
alpha value to be used for the hex string, by default 1.0
@@ -605,7 +605,7 @@ def from_hex(cls, hex: str, alpha: float = 1.0) -> Self:
605605
ManimColor
606606
The ManimColor represented by the hex string
607607
"""
608-
return cls(hex, alpha)
608+
return cls(hex_str, alpha)
609609

610610
@classmethod
611611
def from_hsv(

manim/utils/deprecation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
logger = logging.getLogger("manim")
1717

1818

19-
def _get_callable_info(callable: Callable) -> tuple[str, str]:
19+
def _get_callable_info(callable_: Callable, /) -> tuple[str, str]:
2020
"""Returns type and name of a callable.
2121
2222
Parameters
@@ -30,8 +30,8 @@ def _get_callable_info(callable: Callable) -> tuple[str, str]:
3030
The type and name of the callable. Type can can be one of "class", "method" (for
3131
functions defined in classes) or "function"). For methods, name is Class.method.
3232
"""
33-
what = type(callable).__name__
34-
name = callable.__qualname__
33+
what = type(callable_).__name__
34+
name = callable_.__qualname__
3535
if what == "function" and "." in name:
3636
what = "method"
3737
elif what != "function":

0 commit comments

Comments
 (0)