A community-maintained Python framework for creating mathematical animations.
Flake8 Compat & Code Cleanup (#1140)
GameDungeonafba451c0a26
diff --git a/.flake8 b/.flake8new file mode 100644index 000000000..a56c9abde--- /dev/null+++ b/.flake8@@ -0,0 +1,21 @@+[flake8]+max-line-length = 88+ #Black Compatability+extend-ignore = E203, E266,+ #Style Changes++ #Temp+ F841, B007,+ #I belive these are unfixable+ B006+ #Code Changes - Remove later+ F405, F403, F401, F821, B008, E501, B009, B010, E731+ #docstring Formatting - Remove Later+ RST304, D400, D401, D205, D105, D103, RST210, RST303, D102, D102, D107, RST212, D200, D100, D101,+ D412, D202, RST305, RST301, D301, RST213, D104, RST201, RST215, RST203, D104, D209, RST205, D402,+ D210, RST202++ #Issue #1148 needs to be closed before removal+ A003,+ #Issue #1149 needs to be closed before removal+ W605,\ No newline at end of filediff --git a/.github/workflows/black-pr.yml b/.github/workflows/lint.ymlsimilarity index 82%rename from .github/workflows/black-pr.ymlrename to .github/workflows/lint.ymlindex fb98f2656..619662f98 100644--- a/.github/workflows/black-pr.yml+++ b/.github/workflows/lint.yml@@ -1,8 +1,8 @@-name: black-check+name: Lintingon:pull_request:- branches:- - master+ branches:+ - masterjobs:check-format:@@ -68,3 +68,22 @@ jobs:echo "The Filed changed are `n`n $(git ls-files -m)"exit 1}+ flake-checks:+ runs-on: windows-latest+ steps:+ - name: Set up Python+ uses: actions/setup-python@v2+ with:+ python-version: 3.9++ - name: Checkout the repository+ uses: actions/checkout@v2++ - name: Install Dependencies+ run: |+ pip install poetry+ poetry install++ - name: Run Flake8+ run: |+ poetry run flake8 manimdiff --git a/manim/__main__.py b/manim/__main__.pyindex e32d6d5ab..64f0c8d0e 100644--- a/manim/__main__.py+++ b/manim/__main__.py@@ -63,7 +63,7 @@ def main():server = frame_server_impl.get(input_file)server.start()server.wait_for_termination()- except ModuleNotFoundError as e:+ except ModuleNotFoundError:console.print("Dependencies for the WebGL render are missing. Run ""pip install manim[webgl_renderer] to install them."diff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex 67dbb6227..057f38aad 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -571,11 +571,11 @@ class ManimConfig(MutableMapping):# other logicval = parser["CLI"].get("tex_template_file")if val:- setattr(self, "tex_template_file", val)+ self.tex_template_file = valval = parser["ffmpeg"].get("loglevel")if val:- setattr(self, "ffmpeg_loglevel", val)+ self.ffmpeg_loglevel = valval = parser["jupyter"].get("media_width")if val:diff --git a/manim/animation/creation.py b/manim/animation/creation.pyindex 3470478f0..c265c2989 100644--- a/manim/animation/creation.py+++ b/manim/animation/creation.py@@ -347,8 +347,6 @@ class Unwrite(Write):**kwargs,) -> None:- backwards_rate_func = lambda t: -rate_func(t) + 1-self.vmobject = vmobjectself.run_time = run_timeself.lag_ratio = lag_ratio@@ -358,7 +356,7 @@ class Unwrite(Write):vmobject,run_time=run_time,lag_ratio=lag_ratio,- rate_func=backwards_rate_func,+ rate_func=lambda t: -rate_func(t) + 1,**kwargs,)diff --git a/manim/animation/indication.py b/manim/animation/indication.pyindex 9e68a327e..079c02dca 100644--- a/manim/animation/indication.py+++ b/manim/animation/indication.py@@ -38,7 +38,6 @@ from ..utils.color import GREY, YELLOWfrom ..utils.rate_functions import there_and_back, wiggleif typing.TYPE_CHECKING:- from ..mobject.geometry import Dotfrom ..mobject.mobject import Mobjectdiff --git a/manim/animation/transform.py b/manim/animation/transform.pyindex 8030d97ee..064e71193 100644--- a/manim/animation/transform.py+++ b/manim/animation/transform.py@@ -200,7 +200,7 @@ class ApplyMethod(Transform):self, method: types.MethodType, *args, **kwargs) -> None: # method typing? for args?"""- method is a method of Mobject, ``args`` are arguments for+ Method is a method of Mobject, ``args`` are arguments forthat method. Key word arguments should be passed inas the last arg, as a dict, since ``kwargs`` is forconfiguration of the transform itselfdiff --git a/manim/camera/camera.py b/manim/camera/camera.pyindex c054bcc79..7bf0808ef 100644--- a/manim/camera/camera.py+++ b/manim/camera/camera.py@@ -1,4 +1,4 @@-"A camera converts the mobjects contained in a Scene into an array of pixels."+"""A camera converts the mobjects contained in a Scene into an array of pixels."""__all__ = ["Camera", "BackgroundColoredVMobjectDisplayer"]diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.pyindex 0690d1ea0..22f2d0e13 100644--- a/manim/camera/moving_camera.py+++ b/manim/camera/moving_camera.py@@ -44,7 +44,7 @@ class MovingCamera(Camera):**kwargs):"""- frame is a Mobject, (should almost certainly be a rectangle)+ Frame is a Mobject, (should almost certainly be a rectangle)determining which region of space the camera displays"""self.fixed_dimension = fixed_dimensiondiff --git a/manim/camera/three_d_camera.py b/manim/camera/three_d_camera.pyindex f1316f1a2..55462fd2f 100644--- a/manim/camera/three_d_camera.py+++ b/manim/camera/three_d_camera.py@@ -61,7 +61,7 @@ class ThreeDCamera(Camera):self.theta_tracker = ValueTracker(self.theta)self.distance_tracker = ValueTracker(self.distance)self.gamma_tracker = ValueTracker(self.gamma)- self.fixed_orientation_mobjects = dict()+ self.fixed_orientation_mobjects = {}self.fixed_in_frame_mobjects = set()self.reset_rotation_matrix()diff --git a/manim/grpc/impl/frame_server_impl.py b/manim/grpc/impl/frame_server_impl.pyindex 97b1042eb..37996e0c3 100644--- a/manim/grpc/impl/frame_server_impl.py+++ b/manim/grpc/impl/frame_server_impl.py@@ -215,7 +215,7 @@ class FrameServer(frameserver_pb2_grpc.FrameServerServicer):self.previous_scene = requested_sceneself.previous_scene_index = requested_scene_indexreturn resp- except Exception as e:+ except Exception:traceback.print_exc()def FetchSceneData(self, request, context):@@ -238,7 +238,7 @@ class FrameServer(frameserver_pb2_grpc.FrameServerServicer):else:request.scene.background_color = "#000000"return request- except Exception as e:+ except Exception:traceback.print_exc()def ScriptUpdated(self, request, context):diff --git a/manim/mobject/graph.py b/manim/mobject/graph.pyindex 7683f4e63..ebacde0c7 100644--- a/manim/mobject/graph.py+++ b/manim/mobject/graph.py@@ -48,7 +48,7 @@ def _determine_graph_layout(auto_layout = automatic_layouts[layout](nx_graph, scale=layout_scale, **layout_config)- return dict([(k, np.append(v, [0])) for k, v in auto_layout.items()])+ return {k: np.append(v, [0]) for k, v in auto_layout.items()}elif layout == "tree":return _tree_layout(nx_graph,@@ -76,14 +76,14 @@ def _determine_graph_layout(auto_layout = automatic_layouts["partite"](nx_graph, scale=layout_scale, **layout_config)- return dict([(k, np.append(v, [0])) for k, v in auto_layout.items()])+ return {k: np.append(v, [0]) for k, v in auto_layout.items()}elif layout == "random":# the random layout places coordinates in [0, 1)# we need to rescale manually afterwards...auto_layout = automatic_layouts["random"](nx_graph, **layout_config)for k, v in auto_layout.items():auto_layout[k] = 2 * layout_scale * (v - np.array([0.5, 0.5]))- return dict([(k, np.append(v, [0])) for k, v in auto_layout.items()])+ return {k: np.append(v, [0]) for k, v in auto_layout.items()}else:raise ValueError(f"The layout '{layout}' is neither a recognized automatic layout, "@@ -143,12 +143,10 @@ def _tree_layout(height = max(map(lambda v: result[v][1], result))- return dict(- [- (v, np.array([pos[0], 1 - 2 * pos[1] / height, pos[2]]) * scale / 2)- for v, pos in result.items()- ]- )+ return {+ v: np.array([pos[0], 1 - 2 * pos[1] / height, pos[2]]) * scale / 2+ for v, pos in result.items()+ }class Graph(VMobject):@@ -377,11 +375,11 @@ class Graph(VMobject):self._labels = labelselif isinstance(labels, bool):if labels:- self._labels = dict(- [(v, MathTex(v, fill_color=label_fill_color)) for v in vertices]- )+ self._labels = {+ v: MathTex(v, fill_color=label_fill_color) for v in vertices+ }else:- self._labels = dict()+ self._labels = {}if self._labels and vertex_type is Dot:vertex_type = LabeledDot@@ -391,18 +389,16 @@ class Graph(VMobject):vertex_config = {}default_vertex_config = {}if vertex_config:- default_vertex_config = dict(- [(k, v) for k, v in vertex_config.items() if k not in vertices]- )- self._vertex_config = dict(- [(v, vertex_config.get(v, copy(default_vertex_config))) for v in vertices]- )+ default_vertex_config = {+ k: v for k, v in vertex_config.items() if k not in vertices+ }+ self._vertex_config = {+ v: vertex_config.get(v, copy(default_vertex_config)) for v in vertices+ }for v, label in self._labels.items():self._vertex_config[v]["label"] = label- self.vertices = dict(- [(v, vertex_type(**self._vertex_config[v])) for v in vertices]- )+ self.vertices = {v: vertex_type(**self._vertex_config[v]) for v in vertices}for v in self.vertices:self[v].move_to(self._layout[v])@@ -411,11 +407,11 @@ class Graph(VMobject):edge_config = {}default_edge_config = {}if edge_config:- default_edge_config = dict(- (k, v)+ default_edge_config = {+ k: vfor k, v in edge_config.items()if k not in edges and k[::-1] not in edges- )+ }self._edge_config = {}for e in edges:if e in edge_config:@@ -425,20 +421,15 @@ class Graph(VMobject):else:self._edge_config[e] = copy(default_edge_config)- self.edges = dict(- [- (- (u, v),- edge_type(- self[u].get_center(),- self[v].get_center(),- z_index=-1,- **self._edge_config[(u, v)],- ),- )- for (u, v) in edges- ]- )+ self.edges = {+ (u, v): edge_type(+ self[u].get_center(),+ self[v].get_center(),+ z_index=-1,+ **self._edge_config[(u, v)],+ )+ for (u, v) in edges+ }self.add(*self.vertices.values())self.add(*self.edges.values())diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex ac0032776..13a654403 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -68,7 +68,7 @@ class Mobject(Container):self.init_colors()# OpenGL data.- self.data = dict()+ self.data = {}self.depth_test = Falseself.is_fixed_in_frame = Falseself.gloss = 0.0@@ -1870,7 +1870,7 @@ class Mobject(Container):center=True,**kwargs,):- """sort mobjects next to each other on screen.+ """Sorts mobjects next to each other on screen.Examples--------@@ -2015,7 +2015,7 @@ class Mobject(Container):new_submobs = []for submob, sf in zip(self.submobjects, split_factors):new_submobs.append(submob)- for k in range(1, sf):+ for _ in range(1, sf):new_submobs.append(submob.copy().fade(1))self.submobjects = new_submobsreturn selfdiff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.pyindex 81c7828b2..e7104eff3 100644--- a/manim/mobject/numbers.py+++ b/manim/mobject/numbers.py@@ -133,16 +133,14 @@ class DecimalNumber(VMobject):- num_decimal_places- field_name (e.g. 0 or 0.real)"""- config = dict(- [- (attr, getattr(self, attr))- for attr in [- "include_sign",- "group_with_commas",- "num_decimal_places",- ]+ config = {+ attr: getattr(self, attr)+ for attr in [+ "include_sign",+ "group_with_commas",+ "num_decimal_places",]- )+ }config.update(kwargs)return "".join([@@ -168,7 +166,7 @@ class DecimalNumber(VMobject):)def set_value(self, number, **config):- full_config = dict()+ full_config = {}full_config.update(self.initial_config)full_config.update(config)new_decimal = DecimalNumber(number, **full_config)diff --git a/manim/mobject/opengl_geometry.py b/manim/mobject/opengl_geometry.pyindex f0f8f1788..ae34c8fae 100644--- a/manim/mobject/opengl_geometry.py+++ b/manim/mobject/opengl_geometry.py@@ -88,7 +88,7 @@ class OpenGLTipableVMobject(OpenGLVMobject):Returns a tip that has been stylistically configured,but has not yet been given a position in space."""- config = dict()+ config = {}config.update(self.tip_config)config.update(kwargs)return OpenGLArrowTip(**config)diff --git a/manim/mobject/opengl_mobject.py b/manim/mobject/opengl_mobject.pyindex 9679fc22f..f84ccc682 100644--- a/manim/mobject/opengl_mobject.py+++ b/manim/mobject/opengl_mobject.py@@ -5,19 +5,12 @@ import sysimport modernglfrom functools import wrapsfrom ..utils.color import *-from ..utils.iterables import listifyimport numpy as npfrom .. import configfrom ..constants import *-from ..utils.color import color_gradient--# from ..utils.color import get_colormap_list-from ..utils.color import rgb_to_hex-from ..utils.color import color_to_rgb-# from ..utils.iterables import batch_by_propertyfrom ..utils.iterables import list_updatefrom ..utils.iterables import resize_array@@ -1225,7 +1218,7 @@ class OpenGLMobject:new_submobs = []for submob, sf in zip(self.submobjects, split_factors):new_submobs.append(submob)- for k in range(1, sf):+ for _ in range(1, sf):new_submob = submob.copy()# If the submobject is at all transparent, then# make the copy completely transparent@@ -1416,7 +1409,7 @@ class OpenGLMobject:batches = batch_by_property(shader_wrappers, lambda sw: sw.get_id())result = []- for wrapper_group, sid in batches:+ for wrapper_group, _ in batches:shader_wrapper = wrapper_group[0]if not shader_wrapper.is_valid():continuediff --git a/manim/mobject/probability.py b/manim/mobject/probability.pyindex 5a38438a0..3c76148d5 100644--- a/manim/mobject/probability.py+++ b/manim/mobject/probability.py@@ -199,7 +199,7 @@ class BarChart(VGroup):ticks = VGroup()heights = np.linspace(0, height, self.n_ticks + 1)values = np.linspace(0, self.max_value, self.n_ticks + 1)- for y, value in zip(heights, values):+ for y, _value in zip(heights, values):tick = Line(LEFT, RIGHT)tick.width = self.tick_widthtick.move_to(y * UP)diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.pyindex 75b44c2ab..51c026e84 100644--- a/manim/mobject/svg/code_mobject.py+++ b/manim/mobject/svg/code_mobject.py@@ -310,7 +310,7 @@ class Code(VGroup):number = str(self.line_no_from + line_no)line_numbers_array.append(number)line_numbers = Paragraph(- *[i for i in line_numbers_array],+ *list(line_numbers_array),line_spacing=self.line_spacing,alignment="right",font=self.font,@@ -336,7 +336,7 @@ class Code(VGroup):line_str = line_str + self.code_json[line_no][word_index][0]lines_text.append(self.tab_spaces[line_no] * "\t" + line_str)code = Paragraph(- *[i for i in lines_text],+ *list(lines_text),line_spacing=self.line_spacing,tab_width=self.tab_width,font=self.font,@@ -597,8 +597,8 @@ def insert_line_numbers_in_html(html, line_no_from):html = html.replace(pre_close, "</pre></td></tr></table>")numbers = range(line_no_from, line_no_from + pre.count("\n") + 1)- format = "%" + str(len(str(numbers[-1]))) + "i"- lines = "\n".join(format % i for i in numbers)+ format_lines = "%" + str(len(str(numbers[-1]))) + "i"+ lines = "\n".join(format_lines % i for i in numbers)html = html.replace(pre_open, "<table><tr><td>" + pre_open + lines + "</pre></td><td>" + pre_open)diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.pyindex e96d94535..f82814326 100644--- a/manim/mobject/svg/text_mobject.py+++ b/manim/mobject/svg/text_mobject.py@@ -1223,7 +1223,7 @@ class MarkupText(SVGMobject):colormap = self.extract_color_tags()if len(colormap) > 0:logger.warning(- f'Using <color> tags in MarkupText is deprecated. Please use <span foreground="..."> instead.'+ 'Using <color> tags in MarkupText is deprecated. Please use <span foreground="..."> instead.')gradientmap = self.extract_gradient_tags()@@ -1361,7 +1361,7 @@ class MarkupText(SVGMobject):Removes the ``<gradient>`` tag, as it is not part of Pango's markup and would cause an error."""tags = re.finditer(- '<gradient\s+from="([^"]+)"\s+to="([^"]+)"(\s+offset="([^"]+)")?>(.+?)</gradient>',+ r'<gradient\s+from="([^"]+)"\s+to="([^"]+)"(\s+offset="([^"]+)")?>(.+?)</gradient>',self.original_text,re.S,)@@ -1403,7 +1403,7 @@ class MarkupText(SVGMobject):will be removed."""tags = re.finditer(- '<color\s+col="([^"]+)"(\s+offset="([^"]+)")?>(.+?)</color>',+ r'<color\s+col="([^"]+)"(\s+offset="([^"]+)")?>(.+?)</color>',self.original_text,re.S,)diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.pyindex 8a69a1f56..572bff62d 100644--- a/manim/mobject/types/image_mobject.py+++ b/manim/mobject/types/image_mobject.py@@ -56,7 +56,7 @@ class AbstractImageMobject(Mobject):if self.scale_to_resolution:height = h / self.scale_to_resolution * config["frame_height"]else:- height = 3 ## this is the case for ImageMobjectFromCamera+ height = 3 # this is the case for ImageMobjectFromCameraself.stretch_to_fit_height(height)self.stretch_to_fit_width(height * w / h)diff --git a/manim/mobject/types/opengl_vectorized_mobject.py b/manim/mobject/types/opengl_vectorized_mobject.pyindex 1a9964b80..e73c896ca 100644--- a/manim/mobject/types/opengl_vectorized_mobject.py+++ b/manim/mobject/types/opengl_vectorized_mobject.py@@ -560,7 +560,7 @@ class OpenGLVMobject(OpenGLMobject):def get_anchors_and_handles(self):"""- returns anchors1, handles, anchors2,+ Returns anchors1, handles, anchors2,where (anchors1[i], handles[i], anchors2[i])will be three points defining a quadratic bezier curvefor any i in range(0, len(anchors1))@@ -733,9 +733,9 @@ class OpenGLVMobject(OpenGLMobject):ipc = np.round(n * norms / sum(norms)).astype(int)diff = n - sum(ipc)- for x in range(diff):+ for _ in range(diff):ipc[np.argmin(ipc)] += 1- for x in range(-diff):+ for _ in range(-diff):ipc[np.argmax(ipc)] -= 1new_points = []@@ -1000,11 +1000,11 @@ class OpenGLVMobject(OpenGLMobject):return resultdef get_fill_uniforms(self):- return dict(- is_fixed_in_frame=float(self.is_fixed_in_frame),- gloss=self.gloss,- shadow=self.shadow,- )+ return {+ "is_fixed_in_frame": float(self.is_fixed_in_frame),+ "gloss": self.gloss,+ "shadow": self.shadow,+ }def get_stroke_shader_data(self):points = self.data["points"]diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.pyindex fe7be9dbe..59eb803c1 100644--- a/manim/mobject/types/point_cloud_mobject.py+++ b/manim/mobject/types/point_cloud_mobject.py@@ -28,7 +28,7 @@ class PMobject(Mobject):def add_points(self, points, rgbas=None, color=None, alpha=1):"""- points must be a Nx3 numpy array, as must rgbas if it is not None+ Points must be a Nx3 numpy array, as must rgbas if it is not None"""if not isinstance(points, np.ndarray):points = np.array(points)@@ -115,7 +115,7 @@ class PMobject(Mobject):def sort_points(self, function=lambda p: p[0]):"""- function is any map from R^3 to R+ Function is any map from R^3 to R"""for mob in self.family_members_with_points():indices = np.argsort(np.apply_along_axis(function, 1, mob.points))diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.pyindex f48d75504..4249c24d8 100644--- a/manim/mobject/types/vectorized_mobject.py+++ b/manim/mobject/types/vectorized_mobject.py@@ -1084,7 +1084,6 @@ class VMobject(Mobject):Points generated."""- def insert_n_curves_to_point_list(self, n, points):if len(points) == 1:nppcc = self.n_points_per_cubic_curvereturn np.repeat(points, nppcc * n, 0)diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.pyindex bc7278f15..2d1c6aa7a 100644--- a/manim/mobject/vector_field.py+++ b/manim/mobject/vector_field.py@@ -261,7 +261,7 @@ class StreamLines(VGroup):start_points = self.get_start_points(**self.start_points_generator_config)for point in start_points:points = [point]- for t in np.arange(0, self.virtual_time, dt):+ for _ in np.arange(0, self.virtual_time, dt):last_point = points[-1]points.append(last_point + dt * func(last_point))if get_norm(last_point) > self.cutoff_norm:diff --git a/manim/plugins/import_plugins.py b/manim/plugins/import_plugins.pyindex 2afdfee7b..180b7bb95 100644--- a/manim/plugins/import_plugins.py+++ b/manim/plugins/import_plugins.py@@ -33,9 +33,9 @@ for plugin in pkg_resources.iter_entry_points("manim.plugins"):# it will return a list of modules to add globally# finally add itlists = loaded_plugin()- for l in lists:- exec(f"{l.__name__}=l")- __all__.append(l.__name__)+ for lst in lists:+ exec(f"{lst.__name__}=lst")+ __all__.append(lst.__name__)plugins_requested.remove(plugin.name)else:if plugins_requested != []:diff --git a/manim/plugins/plugins_flags.py b/manim/plugins/plugins_flags.pyindex 5905b3016..0101b631a 100644--- a/manim/plugins/plugins_flags.py+++ b/manim/plugins/plugins_flags.py@@ -10,7 +10,7 @@ import pkg_resourcesfrom manim import console-__all__ = ["list_plugins", "update"]+__all__ = ["list_plugins"]def get_plugins():diff --git a/manim/renderer/shader_wrapper.py b/manim/renderer/shader_wrapper.pyindex fb15c8fae..57a8d4e1d 100644--- a/manim/renderer/shader_wrapper.py+++ b/manim/renderer/shader_wrapper.py@@ -48,8 +48,8 @@ class ShaderWrapper(object):self.vert_indices = vert_indicesself.vert_attributes = vert_data.dtype.namesself.shader_folder = shader_folder- self.uniforms = uniforms or dict()- self.texture_paths = texture_paths or dict()+ self.uniforms = uniforms or {}+ self.texture_paths = texture_paths or {}self.depth_test = depth_testself.render_primitive = str(render_primitive)self.init_program_code()diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.pyindex 926b0684e..b3b8ad528 100644--- a/manim/scene/graph_scene.py+++ b/manim/scene/graph_scene.py@@ -303,7 +303,8 @@ class GraphScene(Scene):dot = Dot().move_to(self.coords_to_point(time, dat))self.add(dot)"""- assert hasattr(self, "x_axis") and hasattr(self, "y_axis")+ assert hasattr(self, "x_axis")+ assert hasattr(self, "y_axis")result = self.x_axis.number_to_point(x)[0] * RIGHTresult += self.y_axis.number_to_point(y)[1] * UPreturn result@@ -618,7 +619,7 @@ class GraphScene(Scene):else:raise ValueError("Invalid input sample type")graph_point = self.input_to_graph_point(sample_input, graph)- if bounded_graph == None:+ if bounded_graph is None:y_point = 0else:y_point = bounded_graph.underlying_function(x)diff --git a/manim/scene/scene.py b/manim/scene/scene.pyindex 32b37d6a1..aa1615f7b 100644--- a/manim/scene/scene.py+++ b/manim/scene/scene.py@@ -135,7 +135,7 @@ class Scene(Container):free_variable_map = inspect.getclosurevars(updater).nonlocalscloned_co_freevars = []cloned_closure = []- for i, free_variable_name in enumerate(updater.__code__.co_freevars):+ for free_variable_name in updater.__code__.co_freevars:free_variable_value = free_variable_map[free_variable_name]# If the referenced variable has not been cloned, raise.diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.pyindex 49d69dc00..6536793cb 100644--- a/manim/scene/scene_file_writer.py+++ b/manim/scene/scene_file_writer.py@@ -549,7 +549,7 @@ class SceneFileWriter(object):len(cached_partial_movies) - config["max_files_cached"])oldest_files_to_delete = sorted(- [partial_movie_file for partial_movie_file in cached_partial_movies],+ cached_partial_movies,key=os.path.getatime,)[:number_files_to_delete]# oldest_file_path = min(cached_partial_movies, key=os.path.getatime)diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.pyindex 3aea2eab1..7b560578e 100644--- a/manim/scene/vector_space_scene.py+++ b/manim/scene/vector_space_scene.py@@ -522,9 +522,6 @@ class LinearTransformationScene(VectorScene):include_foreground_plane=True,background_plane_kwargs={"color": GREY,- "axis_config": {- "stroke_color": LIGHT_GREY,- },"axis_config": {"color": GREY,},@@ -972,8 +969,10 @@ class LinearTransformationScene(VectorScene):AnimationThe animation of the movement."""- for l in self.transformable_labels:- l.target = self.get_vector_label(l.vector.target, l.target_text, **l.kwargs)+ for label in self.transformable_labels:+ label.target = self.get_vector_label(+ label.vector.target, label.target_text, **label.kwargs+ )return self.get_piece_movement(self.transformable_labels)def apply_matrix(self, matrix, **kwargs):diff --git a/manim/utils/bezier.py b/manim/utils/bezier.pyindex 29eb33758..bceb92fe7 100644--- a/manim/utils/bezier.py+++ b/manim/utils/bezier.py@@ -111,7 +111,7 @@ def interpolate(start: int, end: int, alpha: float) -> float:def integer_interpolate(start: float, end: float, alpha: float) -> int:"""- alpha is a float between 0 and 1. This returns+ Alpha is a float between 0 and 1. This returnsan integer between start and end (inclusive) representingappropriate interpolation between them, along with a"residue" representing a new proportion between thediff --git a/manim/utils/color.py b/manim/utils/color.pyindex f1065ed77..cbd749453 100644--- a/manim/utils/color.py+++ b/manim/utils/color.py@@ -289,7 +289,7 @@ def color_to_rgba(color, alpha=1):def rgb_to_color(rgb):try:return Color(rgb=rgb)- except:+ except Exception:return Color(WHITE)diff --git a/manim/utils/config_ops.py b/manim/utils/config_ops.pyindex e7741054c..a3ee8bad1 100644--- a/manim/utils/config_ops.py+++ b/manim/utils/config_ops.py@@ -20,7 +20,7 @@ def merge_dicts_recursively(*dicts):When values are dictionaries, it is applied recursively"""- result = dict()+ result = {}all_items = it.chain(*[d.items() for d in dicts])for key, value in all_items:if key in result and isinstance(result[key], dict) and isinstance(value, dict):@@ -40,5 +40,5 @@ def update_dict_recursively(current_dict, *others):class DictAsObject(object):- def __init__(self, dict):- self.__dict__ = dict+ def __init__(self, dictin):+ self.__dict__ = dictindiff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.pyindex 433baba46..6e31fd9e9 100644--- a/manim/utils/ipython_magic.py+++ b/manim/utils/ipython_magic.py@@ -27,7 +27,7 @@ else:class ManimMagic(Magics):def __init__(self, shell):super(ManimMagic, self).__init__(shell)- self.rendered_files = dict()+ self.rendered_files = {}@needs_local_scope@line_cell_magicdiff --git a/manim/utils/iterables.py b/manim/utils/iterables.pyindex c561180b8..2e0d95ca2 100644--- a/manim/utils/iterables.py+++ b/manim/utils/iterables.py@@ -49,14 +49,14 @@ def resize_with_interpolation(nparray, length):)-def remove_list_redundancies(l):+def remove_list_redundancies(lst):"""Used instead of list(set(l)) to maintain orderKeeps the last occurrence of each element"""reversed_result = []used = set()- for x in reversed(l):+ for x in reversed(lst):if x not in used:reversed_result.append(x)used.add(x)@@ -169,4 +169,4 @@ def remove_nones(sequence):def concatenate_lists(*list_of_lists):- return [item for l in list_of_lists for item in l]+ return [item for lst in list_of_lists for item in lst]diff --git a/manim/utils/space_ops.py b/manim/utils/space_ops.pyindex ecdcdf03c..443a6a6a8 100644--- a/manim/utils/space_ops.py+++ b/manim/utils/space_ops.py@@ -318,7 +318,7 @@ def midpoint(point1, point2):def line_intersection(line1, line2):"""- return intersection point of two lines,+ Returns intersection point of two lines,each defined with a pair of vectors determiningthe end points"""@@ -428,7 +428,7 @@ def earclip_triangulation(verts, ring_ends):rings = [list(range(e0, e1)) for e0, e1 in zip([0, *ring_ends], ring_ends)]attached_rings = rings[:1]detached_rings = rings[1:]- loop_connections = dict()+ loop_connections = {}while detached_rings:i_range, j_range = [@@ -474,7 +474,7 @@ def earclip_triangulation(verts, ring_ends):# Find an ordering of indices walking around the polygonindices = []i = 0- for x in range(len(verts) + len(ring_ends) - 1):+ for _ in range(len(verts) + len(ring_ends) - 1):# starting = Falseif i in loop_connections:j = loop_connections[i]diff --git a/poetry.lock b/poetry.lockindex 6a3329e3a..82ba10e59 100644--- a/poetry.lock+++ b/poetry.lock@@ -205,7 +205,7 @@ optional = falsepython-versions = "*"[package.extras]-test = ["flake8 (3.7.8)", "hypothesis (3.55.3)"]+test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"][[package]]name = "contextvars"@@ -269,6 +269,112 @@ category = "main"optional = truepython-versions = ">=2.7"+[[package]]+name = "flake8"+version = "3.9.0"+description = "the modular source code checker: pep8 pyflakes and co"+category = "dev"+optional = false+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"++[package.dependencies]+importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}+mccabe = ">=0.6.0,<0.7.0"+pycodestyle = ">=2.7.0,<2.8.0"+pyflakes = ">=2.3.0,<2.4.0"++[[package]]+name = "flake8-bugbear"+version = "21.3.2"+description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle."+category = "dev"+optional = false+python-versions = ">=3.6"++[package.dependencies]+attrs = ">=19.2.0"+flake8 = ">=3.0.0"++[package.extras]+dev = ["coverage", "black", "hypothesis", "hypothesmith"]++[[package]]+name = "flake8-builtins"+version = "1.5.3"+description = "Check for python builtins being used as variables or parameters."+category = "dev"+optional = false+python-versions = "*"++[package.dependencies]+flake8 = "*"++[package.extras]+test = ["coverage", "coveralls", "mock", "pytest", "pytest-cov"]++[[package]]+name = "flake8-comprehensions"+version = "3.4.0"+description = "A flake8 plugin to help you write better list/set/dict comprehensions."+category = "dev"+optional = false+python-versions = ">=3.6"++[package.dependencies]+flake8 = ">=3.0,<3.2.0 || >3.2.0,<4"+importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}++[[package]]+name = "flake8-docstrings"+version = "1.6.0"+description = "Extension for flake8 which uses pydocstyle to check docstrings"+category = "dev"+optional = false+python-versions = "*"++[package.dependencies]+flake8 = ">=3"+pydocstyle = ">=2.1"++[[package]]+name = "flake8-logging-format"+version = "0.6.0"+description = "Flake8 extension to validate (lack of) logging format strings"+category = "dev"+optional = false+python-versions = "*"++[[package]]+name = "flake8-plugin-utils"+version = "1.3.1"+description = "The package provides base classes and utils for flake8 plugin writing"+category = "dev"+optional = false+python-versions = ">=3.6,<4.0"++[[package]]+name = "flake8-pytest-style"+version = "1.4.0"+description = "A flake8 plugin checking common style issues or inconsistencies with pytest-based tests."+category = "dev"+optional = false+python-versions = ">=3.6,<4.0"++[package.dependencies]+flake8-plugin-utils = ">=1.3.1,<2.0.0"++[[package]]+name = "flake8-rst-docstrings"+version = "0.0.14"+description = "Python docstring reStructuredText (RST) validator"+category = "dev"+optional = false+python-versions = "*"++[package.dependencies]+flake8 = ">=3.0.0"+restructuredtext_lint = "*"+[[package]]name = "glcontext"version = "2.3.3"@@ -355,7 +461,7 @@ zipp = ">=0.5"[package.extras]docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]-testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "pytest-enabler", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]+testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "pytest-enabler", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"][[package]]name = "iniconfig"@@ -447,7 +553,7 @@ python-versions = ">=3.6"parso = ">=0.8.0,<0.9.0"[package.extras]-qa = ["flake8 (3.8.3)", "mypy (0.782)"]+qa = ["flake8 (==3.8.3)", "mypy (==0.782)"]testing = ["Django (<3.1)", "colorama", "docopt", "pytest (<6.0.0)"][[package]]@@ -724,7 +830,7 @@ pyrr = ">=0.10.3,<1"pysdl2 = ["pysdl2"]pyside2 = ["PySide2 (<6)"]glfw = ["glfw"]-pygame = ["pygame (2.0.0.dev10)"]+pygame = ["pygame (==2.0.0.dev10)"]pyqt5 = ["pyqt5"]pywavefront = ["pywavefront (>=1.2.0,<2)"]tk = ["pyopengltk (>=0.0.3)"]@@ -808,11 +914,11 @@ testpath = "*"traitlets = ">=4.2"[package.extras]-all = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (0.2.2)", "tornado (>=4.0)", "sphinx (>=1.5.1)", "sphinx-rtd-theme", "nbsphinx (>=0.2.12)", "ipython"]+all = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (==0.2.2)", "tornado (>=4.0)", "sphinx (>=1.5.1)", "sphinx-rtd-theme", "nbsphinx (>=0.2.12)", "ipython"]docs = ["sphinx (>=1.5.1)", "sphinx-rtd-theme", "nbsphinx (>=0.2.12)", "ipython"]serve = ["tornado (>=4.0)"]-test = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (0.2.2)"]-webpdf = ["pyppeteer (0.2.2)"]+test = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (==0.2.2)"]+webpdf = ["pyppeteer (==0.2.2)"][[package]]name = "nbformat"@@ -929,7 +1035,7 @@ optional = truepython-versions = ">=3.6"[package.extras]-qa = ["flake8 (3.8.3)", "mypy (0.782)"]+qa = ["flake8 (==3.8.3)", "mypy (==0.782)"]testing = ["docopt", "pytest (<6.0.0)"][[package]]@@ -1038,6 +1144,14 @@ category = "main"optional = falsepython-versions = ">=3.6, <4"+[[package]]+name = "pycodestyle"+version = "2.7.0"+description = "Python style guide checker"+category = "dev"+optional = false+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"+[[package]]name = "pycparser"version = "2.20"@@ -1046,6 +1160,17 @@ category = "main"optional = truepython-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"+[[package]]+name = "pydocstyle"+version = "6.0.0"+description = "Python docstring style checker"+category = "dev"+optional = false+python-versions = ">=3.6"++[package.dependencies]+snowballstemmer = "*"+[[package]]name = "pydub"version = "0.25.1"@@ -1054,6 +1179,14 @@ category = "main"optional = falsepython-versions = "*"+[[package]]+name = "pyflakes"+version = "2.3.0"+description = "passive checker of Python programs"+category = "dev"+optional = false+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"+[[package]]name = "pyglet"version = "1.5.15"@@ -1086,7 +1219,7 @@ mccabe = ">=0.6,<0.7"toml = ">=0.7.1"[package.extras]-docs = ["sphinx (3.5.1)", "python-docs-theme (2020.12)"]+docs = ["sphinx (==3.5.1)", "python-docs-theme (==2020.12)"][[package]]name = "pyparsing"@@ -1216,7 +1349,18 @@ python-versions = "*"[package.extras]security = ["cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0.14)"]-socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"]+socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]++[[package]]+name = "restructuredtext-lint"+version = "1.3.2"+description = "reStructuredText linter"+category = "dev"+optional = false+python-versions = "*"++[package.dependencies]+docutils = ">=0.11,<1.0"[[package]]name = "rich"@@ -1523,7 +1667,7 @@ webgl_renderer = ["grpcio", "grpcio-tools", "watchdog"][metadata]lock-version = "1.1"python-versions = "^3.6.2"-content-hash = "a797ac53cad4b1e2802672221d348981018526c8fbbee0aa2786f14b9c19cd6d"+content-hash = "b46763cf01316ccac3f762570dc6e8c9a2f758bdd7448015b784bb4552b79c0c"[metadata.files]alabaster = [@@ -1675,6 +1819,40 @@ entrypoints = [{file = "entrypoints-0.3-py2.py3-none-any.whl", hash = "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19"},{file = "entrypoints-0.3.tar.gz", hash = "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"},]+flake8 = [+ {file = "flake8-3.9.0-py2.py3-none-any.whl", hash = "sha256:12d05ab02614b6aee8df7c36b97d1a3b2372761222b19b58621355e82acddcff"},+ {file = "flake8-3.9.0.tar.gz", hash = "sha256:78873e372b12b093da7b5e5ed302e8ad9e988b38b063b61ad937f26ca58fc5f0"},+]+flake8-bugbear = [+ {file = "flake8-bugbear-21.3.2.tar.gz", hash = "sha256:cadce434ceef96463b45a7c3000f23527c04ea4b531d16c7ac8886051f516ca0"},+ {file = "flake8_bugbear-21.3.2-py36.py37.py38-none-any.whl", hash = "sha256:5d6ccb0c0676c738a6e066b4d50589c408dcc1c5bf1d73b464b18b73cd6c05c2"},+]+flake8-builtins = [+ {file = "flake8-builtins-1.5.3.tar.gz", hash = "sha256:09998853b2405e98e61d2ff3027c47033adbdc17f9fe44ca58443d876eb00f3b"},+ {file = "flake8_builtins-1.5.3-py2.py3-none-any.whl", hash = "sha256:7706babee43879320376861897e5d1468e396a40b8918ed7bccf70e5f90b8687"},+]+flake8-comprehensions = [+ {file = "flake8-comprehensions-3.4.0.tar.gz", hash = "sha256:c00039be9f3959a26a98da3024f0fe809859bf1753ccb90e228cc40f3ac31ca7"},+ {file = "flake8_comprehensions-3.4.0-py3-none-any.whl", hash = "sha256:7258a28e229fb9a8d16370b9c47a7d66396ba0201abb06c9d11df41b18ed64c4"},+]+flake8-docstrings = [+ {file = "flake8-docstrings-1.6.0.tar.gz", hash = "sha256:9fe7c6a306064af8e62a055c2f61e9eb1da55f84bb39caef2b84ce53708ac34b"},+ {file = "flake8_docstrings-1.6.0-py2.py3-none-any.whl", hash = "sha256:99cac583d6c7e32dd28bbfbef120a7c0d1b6dde4adb5a9fd441c4227a6534bde"},+]+flake8-logging-format = [+ {file = "flake8-logging-format-0.6.0.tar.gz", hash = "sha256:ca5f2b7fc31c3474a0aa77d227e022890f641a025f0ba664418797d979a779f8"},+]+flake8-plugin-utils = [+ {file = "flake8-plugin-utils-1.3.1.tar.gz", hash = "sha256:6e996bc24ebe327558f24efd106f1be5f0c033c8cbb6eed815631f73d487f1c9"},+ {file = "flake8_plugin_utils-1.3.1-py3-none-any.whl", hash = "sha256:efdbf9d15b18f72b7c348dd360f30e7cf3e73aa67ff832d5343eb5aa1115f250"},+]+flake8-pytest-style = [+ {file = "flake8-pytest-style-1.4.0.tar.gz", hash = "sha256:f51bf5c8f657ad4b4938bfedb9a5b84fb0885f72ac07b406ebb7f5ea83f8b74e"},+ {file = "flake8_pytest_style-1.4.0-py3-none-any.whl", hash = "sha256:f8b6f24b15b28f317eee1bd354f38427007d527774e2ac8ae8b936e6e7eda604"},+]+flake8-rst-docstrings = [+ {file = "flake8-rst-docstrings-0.0.14.tar.gz", hash = "sha256:8f8bcb18f1408b506dd8ba2c99af3eac6128f6911d4bf6ff874b94caa70182a2"},+]glcontext = [{file = "glcontext-2.3.3-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:f518379551a2b60d45c1eec23759cb1ee85517d4b943fc31530b6ab13e304fe4"},{file = "glcontext-2.3.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:d3a8fbc27f43766d168bae02474790459f4050adeb25832ff0a227cc5006c933"},@@ -2312,14 +2490,26 @@ pycairo = [{file = "pycairo-1.20.0-cp39-cp39-win_amd64.whl", hash = "sha256:57166119e424d71eccdba6b318bd731bdabd17188e2ba10d4f315f7bf16ace3f"},{file = "pycairo-1.20.0.tar.gz", hash = "sha256:5695a10cb7f9ae0d01f665b56602a845b0a8cb17e2123bfece10c2e58552468c"},]+pycodestyle = [+ {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"},+ {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"},+]pycparser = [{file = "pycparser-2.20-py2.py3-none-any.whl", hash = "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705"},{file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"},]+pydocstyle = [+ {file = "pydocstyle-6.0.0-py3-none-any.whl", hash = "sha256:d4449cf16d7e6709f63192146706933c7a334af7c0f083904799ccb851c50f6d"},+ {file = "pydocstyle-6.0.0.tar.gz", hash = "sha256:164befb520d851dbcf0e029681b91f4f599c62c5cd8933fd54b1bfbd50e89e1f"},+]pydub = [{file = "pydub-0.25.1-py2.py3-none-any.whl", hash = "sha256:65617e33033874b59d87db603aa1ed450633288aefead953b30bded59cb599a6"},{file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},]+pyflakes = [+ {file = "pyflakes-2.3.0-py2.py3-none-any.whl", hash = "sha256:910208209dcea632721cb58363d0f72913d9e8cf64dc6f8ae2e02a3609aba40d"},+ {file = "pyflakes-2.3.0.tar.gz", hash = "sha256:e59fd8e750e588358f1b8885e5a4751203a0516e0ee6d34811089ac294c8806f"},+]pyglet = [{file = "pyglet-1.5.15-py3-none-any.whl", hash = "sha256:4401cc176580e4e17e2df8bbf7536f27e691327dc3f38f209a12f1859c70aed2"},{file = "pyglet-1.5.15.zip", hash = "sha256:da9d8337388cedabf1f1c5dc21a45bb2b0e5327fba47f996c8573818c3dfa478"},@@ -2464,6 +2654,9 @@ requests = [{file = "requests-2.15.1-py2.py3-none-any.whl", hash = "sha256:ff753b2196cd18b1bbeddc9dcd5c864056599f7a7d9a4fb5677e723efa2b7fb9"},{file = "requests-2.15.1.tar.gz", hash = "sha256:e5659b9315a0610505e050bb7190bf6fa2ccee1ac295f2b760ef9d8a03ebbb2e"},]+restructuredtext-lint = [+ {file = "restructuredtext_lint-1.3.2.tar.gz", hash = "sha256:d3b10a1fe2ecac537e51ae6d151b223b78de9fafdd50e5eb6b08c243df173c80"},+]rich = [{file = "rich-6.2.0-py3-none-any.whl", hash = "sha256:fa55d5d6ba9a0df1f1c95518891b57b13f1d45548a9a198a87b093fceee513ec"},{file = "rich-6.2.0.tar.gz", hash = "sha256:f99c877277906e1ff83b135c564920590ba31188f424dcdb5d1cae652a519b4b"},diff --git a/pyproject.toml b/pyproject.tomlindex b2839b8de..626881a9e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -56,6 +56,14 @@ pylint = "*"guzzle_sphinx_theme = "*"recommonmark = "*"matplotlib = "^3.3.2"+flake8 = "^3.9.0"+flake8-bugbear = "^21.3.2"+flake8-builtins = "^1.5.3"+flake8-comprehensions = "^3.4.0"+flake8-pytest-style = "^1.4.0"+flake8-logging-format = "^0.6.0"+flake8-rst-docstrings = "^0.0.14"+flake8-docstrings = "^1.6.0"[tool.poetry.dev-dependencies.black]version = "^20.8b1"