Fixed Flake8 (#2410)

* Auto Type

* Revert "Auto Type"

This reverts commit a458905369.

* Fixed Flake
This commit is contained in:
GameDungeon 2021-12-31 17:59:28 -06:00 committed by GitHub
commit f993ee02ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 53 additions and 51 deletions

23
.flake8
View file

@ -1,32 +1,33 @@
[flake8]
# Exclude the grpc generated code
exclude = ./.*,manim/grpc/gen/*
exclude = ./manim/grpc/gen/*
max-complexity = 15
max-line-length = 88
statistics = True
# Prevents some flake8-rst-docstrings errors
rst-roles = attr,class,func,meth,mod,obj,ref,doc,exc
rst-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-builtins
A001, A002, A003,
# Plug-in: flake8-bugbear
B006, B008, B009, B010,
B006, B007, B008, B009, B010,
# Plug-in: flake8-simplify
SIM105, SIM106, SIM119,
# Plug-in: flake8-comprehensions
C408,
C901
# Plug-in: flake8-pytest-style
PT001, 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-docstrings
RST201, RST203, RST210, RST212, RST213, RST215,
RST301,
# I believe B009, B010, and F841 can be removed but I don't want to break things

View file

@ -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_graph_attrs = {
"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_node_attrs = {
"penwidth": 0,
"shape": "box",
"width": 0.05,
"height": 0.05,
"margin": 0.05,
}
inheritance_edge_attrs = dict(
penwidth=1,
)
inheritance_edge_attrs = {
"penwidth": 1,
}
html_js_files = [
"responsiveSvg.js",

View file

@ -295,8 +295,8 @@ class InlineShaderExample(Scene):
shader = Shader(
self.renderer.context,
source=dict(
vertex_shader="""
source={
"vertex_shader": """
#version 330
in vec4 in_vert;
@ -312,7 +312,7 @@ class InlineShaderExample(Scene):
gl_Position = clip_space_vertex;
}
""",
fragment_shader="""
"fragment_shader": """
#version 330
in 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(

View file

@ -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]

View file

@ -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:

View file

@ -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 = {}

View file

@ -407,8 +407,8 @@ class FullScreenQuad(Mesh):
shader = Shader(
context,
source=dict(
vertex_shader="""
source={
"vertex_shader": """
#version 330
in 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(

View file

@ -747,12 +747,14 @@ class Scene:
"""
Creates _MethodAnimations from any _AnimationBuilders and updates animation
kwargs with kwargs passed to play().
Parameters
----------
*args : Tuple[:class:`Animation`]
Animations to be played.
**kwargs
Configuration for the call to play().
Returns
-------
Tuple[:class:`Animation`]

View file

@ -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(

View file

@ -21,6 +21,7 @@ STRAIGHT_PATH_THRESHOLD = 0.01
PATH_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",

View file

@ -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 = None
real_test = _make_test_comparing_frames(
file_path=_control_data_path(

View file

@ -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}")

View file

@ -11,8 +11,8 @@ def test_guarantee_existence(tmp_path):
guarantee_existence(test_dir)
# test if file dir got created
assert_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 deleted
guarantee_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"):
pass
guarantee_empty_existence(test_dir)
# test if dir got created

View file

@ -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,
)