A community-maintained Python framework for creating mathematical animations.
Fixed Flake8 (#2410)
GameDungeonf993ee02ea02
diff --git a/.flake8 b/.flake8index 137619889..24aa4d019 100644--- a/.flake8+++ b/.flake8@@ -1,32 +1,33 @@[flake8]# Exclude the grpc generated code-exclude = ./.*,manim/grpc/gen/*+exclude = ./manim/grpc/gen/*max-complexity = 15max-line-length = 88statistics = True# Prevents some flake8-rst-docstrings errorsrst-roles = attr,class,func,meth,mod,obj,ref,doc,excrst-directives = manim, SEEALSO, seealso-# Adds some more bugbear checks-select = B9+docstring-convention=numpy- # Black Compatibility-extend-ignore = E203, W503,+select = A,A00,B,B9,C4,C90,D,E,F,F,PT,RST,SIM,W- # Unused imports, wildcard imports, and unused variables- F401, F403, F405, F841, E501,+ # General Compatibility+extend-ignore = E203, W503, D202, D212, D213, D404++ # Misc+ F401, F403, F405, F841, E501, E731, E402, F811, F821,# Plug-in: flake8-builtinsA001, A002, A003,# Plug-in: flake8-bugbear- B006, B008, B009, B010,+ B006, B007, B008, B009, B010,# Plug-in: flake8-simplifySIM105, SIM106, SIM119,# Plug-in: flake8-comprehensions- C408,+ C901# Plug-in: flake8-pytest-stylePT001, PT004, PT006, PT011, PT018, PT022, PT023,@@ -35,10 +36,8 @@ extend-ignore = E203, W503,D100, D101, D102, D103, D104, D105, D106, D107,D200, D202, D204, D205, D209,D301,- D400, D401, D402, D403, D412, D414,+ D400, D401, D402, D403, D405, D406, D407, D409, D411, D412, D414,# Plug-in: flake8-rst-docstringsRST201, RST203, RST210, RST212, RST213, RST215,RST301,--# I believe B009, B010, and F841 can be removed but I don't want to break thingsdiff --git a/docs/source/conf.py b/docs/source/conf.pyindex c4bdb3f9f..0dd36b626 100644--- a/docs/source/conf.py+++ b/docs/source/conf.py@@ -143,25 +143,25 @@ ogp_site_url = "https://docs.manim.community/"# inheritance_graph settings-inheritance_graph_attrs = dict(- concentrate=True,- size='""',- splines="ortho",- nodesep=0.1,- ranksep=0.2,-)--inheritance_node_attrs = dict(- penwidth=0,- shape="box",- width=0.05,- height=0.05,- margin=0.05,-)--inheritance_edge_attrs = dict(- penwidth=1,-)+inheritance_graph_attrs = {+ "concentrate": True,+ "size": '""',+ "splines": "ortho",+ "nodesep": 0.1,+ "ranksep": 0.2,+}++inheritance_node_attrs = {+ "penwidth": 0,+ "shape": "box",+ "width": 0.05,+ "height": 0.05,+ "margin": 0.05,+}++inheritance_edge_attrs = {+ "penwidth": 1,+}html_js_files = ["responsiveSvg.js",diff --git a/example_scenes/opengl.py b/example_scenes/opengl.pyindex 864e93ccd..e2a27f831 100644--- a/example_scenes/opengl.py+++ b/example_scenes/opengl.py@@ -295,8 +295,8 @@ class InlineShaderExample(Scene):shader = Shader(self.renderer.context,- source=dict(- vertex_shader="""+ source={+ "vertex_shader": """#version 330in vec4 in_vert;@@ -312,7 +312,7 @@ class InlineShaderExample(Scene):gl_Position = clip_space_vertex;}""",- fragment_shader="""+ "fragment_shader": """#version 330in vec4 v_color;@@ -322,7 +322,7 @@ class InlineShaderExample(Scene):frag_color = v_color;}""",- ),+ },)shader.set_uniform("u_model_view_matrix", opengl.view_matrix())shader.set_uniform(diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.pyindex bc9ae1acc..98bb7755e 100644--- a/manim/camera/moving_camera.py+++ b/manim/camera/moving_camera.py@@ -213,7 +213,7 @@ class MovingCamera(Camera):continue# initialize scene critical points with first mobjects critical points- if scene_critical_x_left == None:+ if scene_critical_x_left is None:scene_critical_x_left = m.get_critical_point(LEFT)[0]scene_critical_x_right = m.get_critical_point(RIGHT)[0]scene_critical_y_up = m.get_critical_point(UP)[1]diff --git a/manim/cli/new/group.py b/manim/cli/new/group.pyindex 297a9c01e..07ffba2b0 100644--- a/manim/cli/new/group.py+++ b/manim/cli/new/group.py@@ -104,7 +104,7 @@ def project(default_settings, **args):)else:project_name.mkdir()- new_cfg = dict()+ new_cfg = {}new_cfg_path = Path.resolve(project_name / "manim.cfg")if not default_settings:diff --git a/manim/mobject/graph.py b/manim/mobject/graph.pyindex 52c495330..d997aff7a 100644--- a/manim/mobject/graph.py+++ b/manim/mobject/graph.py@@ -114,7 +114,7 @@ def _tree_layout(# https://github.com/sagemath/sage/blob/cc60cfebc4576fed8b01f0fc487271bdee3cefed/src/sage/graphs/graph_plot.py#L1447# Always make a copy of the children because they get eaten- stack = [[u for u in children[root_vertex]]]+ stack = [list(children[root_vertex]).copy()]stick = [root_vertex]parent = {u: root_vertex for u in children[root_vertex]}pos = {}diff --git a/manim/renderer/shader.py b/manim/renderer/shader.pyindex 49733fb3a..e6f64e8fc 100644--- a/manim/renderer/shader.py+++ b/manim/renderer/shader.py@@ -407,8 +407,8 @@ class FullScreenQuad(Mesh):shader = Shader(context,- source=dict(- vertex_shader="""+ source={+ "vertex_shader": """#version 330in vec4 in_vert;uniform mat4 u_model_view_matrix;@@ -419,8 +419,8 @@ class FullScreenQuad(Mesh):gl_Position = clip_space_vertex;}}""",- fragment_shader=fragment_shader_source,- ),+ "fragment_shader": fragment_shader_source,+ },)attributes = np.zeros(6, dtype=[("in_vert", np.float32, (4,))])attributes["in_vert"] = np.array(diff --git a/manim/scene/scene.py b/manim/scene/scene.pyindex ee2c38787..8a98f7b88 100644--- a/manim/scene/scene.py+++ b/manim/scene/scene.py@@ -747,12 +747,14 @@ class Scene:"""Creates _MethodAnimations from any _AnimationBuilders and updates animationkwargs with kwargs passed to play().+Parameters----------*args : Tuple[:class:`Animation`]Animations to be played.**kwargsConfiguration for the call to play().+Returns-------Tuple[:class:`Animation`]diff --git a/manim/scene/three_d_scene.py b/manim/scene/three_d_scene.pyindex ea70be1c1..b9f659c24 100644--- a/manim/scene/three_d_scene.py+++ b/manim/scene/three_d_scene.py@@ -132,7 +132,7 @@ class ThreeDScene(Scene):}cam.add_updater(lambda m, dt: methods[about](rate * dt))self.add(self.camera)- except:+ except Exception:raise ValueError("Invalid ambient rotation angle.")def stop_ambient_camera_rotation(self, about="theta"):@@ -152,7 +152,7 @@ class ThreeDScene(Scene):self.remove(x)else:self.camera.clear_updaters()- except:+ except Exception:raise ValueError("Invalid ambient rotation angle.")def begin_3dillusion_camera_rotation(diff --git a/manim/utils/paths.py b/manim/utils/paths.pyindex 23d13ee6b..e5025cc90 100644--- a/manim/utils/paths.py+++ b/manim/utils/paths.py@@ -21,6 +21,7 @@ STRAIGHT_PATH_THRESHOLD = 0.01PATH_FUNC_TYPE = Callable[[np.ndarray, np.ndarray, float], np.ndarray]+# Remove `*args` and the `if` inside the functions when removing deprecation@deprecated_params(params="start_points, end_points, alpha",diff --git a/manim/utils/testing/frames_comparison.py b/manim/utils/testing/frames_comparison.pyindex 7d38965e2..322e686a9 100644--- a/manim/utils/testing/frames_comparison.py+++ b/manim/utils/testing/frames_comparison.py@@ -105,7 +105,7 @@ def frames_comparison(setting_test = request.config.getoption("--set_test")try:test_file_path = tested_scene_construct.__globals__["__file__"]- except:+ except Exception:test_file_path = Nonereal_test = _make_test_comparing_frames(file_path=_control_data_path(diff --git a/scripts/dev_changelog.py b/scripts/dev_changelog.pyindex c6c006d17..921dd309e 100755--- a/scripts/dev_changelog.py+++ b/scripts/dev_changelog.py@@ -168,7 +168,7 @@ def get_summary(body):if has_changelog_pattern:return has_changelog_pattern.group()[22:-21].strip()- except:+ except Exception:print(f"Error parsing body for changelog: {body}")diff --git a/tests/test_file_ops.py b/tests/test_file_ops.pyindex 3be484d60..60fdc75a0 100644--- a/tests/test_file_ops.py+++ b/tests/test_file_ops.py@@ -11,8 +11,8 @@ def test_guarantee_existence(tmp_path):guarantee_existence(test_dir)# test if file dir got createdassert_dir_exists(test_dir)- f = open(os.path.join(test_dir, "test.txt"), "x")- f.close()+ with open(os.path.join(test_dir, "test.txt"), "x") as f:+ pass# test if file didn't get deletedguarantee_existence(test_dir)@@ -20,8 +20,8 @@ def test_guarantee_existence(tmp_path):def test_guarantee_empty_existence(tmp_path):test_dir = os.path.join(tmp_path, "test")os.mkdir(test_dir)- f = open(os.path.join(test_dir, "test.txt"), "x")- f.close()+ with open(os.path.join(test_dir, "test.txt"), "x"):+ passguarantee_empty_existence(test_dir)# test if dir got createddiff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.pyindex fcec71bcd..6c1915e66 100644--- a/tests/test_graphical_units/test_axes.py+++ b/tests/test_graphical_units/test_axes.py@@ -154,7 +154,7 @@ def test_plot_line_graph(scene):x_values=[0, 1.5, 2, 2.8, 4, 6.25],y_values=[1, 3, 2.25, 4, 2.5, 1.75],line_color=GOLD_E,- vertex_dot_style=dict(stroke_width=3, fill_color=PURPLE),+ vertex_dot_style={"stroke_width": 3, "fill_color": PURPLE},vertex_dot_radius=0.04,stroke_width=4,)