Skip to content

Commit

Permalink
Use Different Temporary Variables to Satisfy MyPy
Browse files Browse the repository at this point in the history
* Updated `Edge.makeSpline()` to use different temporary variables in
the several for loops in the function body. Python for
[loop target variables
leak](https://eli.thegreenplace.net/2015/the-scope-of-index-variables-in-pythons-for-loops/)
to the function (or enclosing module) scope, and MyPy doesn't accept
[reusing the same variable name with a different
type](python/mypy#1174) (except in specific
cases, and when `--allow-redefinition` is used).
  • Loading branch information
pavpen committed Feb 15, 2021
1 parent 59c7283 commit d487965
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,8 @@ def makeSpline(
spline_builder = GeomAPI_Interpolate(pnts, periodic, tol)
else:
parameters_array = TColStd_HArray1OfReal(1, len(parameters))
for index, value in enumerate(parameters):
parameters_array.SetValue(index + 1, value)
for p_index, p_value in enumerate(parameters):
parameters_array.SetValue(p_index + 1, p_value)

spline_builder = GeomAPI_Interpolate(pnts, parameters_array, periodic, tol)

Expand All @@ -1458,10 +1458,10 @@ def makeSpline(
# Specify a tangent for each interpolation point:
tangents_array = TColgp_Array1OfVec(1, len(tangents))
tangent_enabled_array = TColStd_HArray1OfBoolean(1, len(tangents))
for index, value in enumerate(tangents):
tangent_enabled_array.SetValue(index + 1, value is not None)
tangent_vec = value if value is not None else Vector()
tangents_array.SetValue(index + 1, tangent_vec.wrapped)
for t_index, t_value in enumerate(tangents):
tangent_enabled_array.SetValue(t_index + 1, t_value is not None)
tangent_vec = t_value if t_value is not None else Vector()
tangents_array.SetValue(t_index + 1, tangent_vec.wrapped)

spline_builder.Load(tangents_array, tangent_enabled_array, scale)

Expand Down

0 comments on commit d487965

Please sign in to comment.