From b1789ae7d2ff043987a1b7ae0ac3f9ab33de7c72 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 25 Feb 2021 20:03:53 -0600 Subject: [PATCH] [PD] Fix minor static analysis issues in FCGear LGTM has identified a number of minor issues with the FCGear Part Design scripts. This commit addresses each of them, and also corrects two minor spelling errors in the dialog. None of the errors or their fixes are expected to result in changes to the functionality of the script. --- src/Mod/PartDesign/fcgear/fcgear.py | 4 ++-- src/Mod/PartDesign/fcgear/fcgeardialog.py | 8 ++++++-- src/Mod/PartDesign/fcgear/involute.py | 2 +- src/Mod/PartDesign/fcgear/svggear.py | 3 +-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/fcgear/fcgear.py b/src/Mod/PartDesign/fcgear/fcgear.py index 3ae79c75f0..d5ade2e154 100644 --- a/src/Mod/PartDesign/fcgear/fcgear.py +++ b/src/Mod/PartDesign/fcgear/fcgear.py @@ -15,10 +15,10 @@ # License along with FCGear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -from math import cos, sin, pi, acos, asin, atan, sqrt +from math import acos import FreeCAD, Part -from FreeCAD import Base, Console +from FreeCAD import Base from . import involute rotate = involute.rotate diff --git a/src/Mod/PartDesign/fcgear/fcgeardialog.py b/src/Mod/PartDesign/fcgear/fcgeardialog.py index 435ec50f90..cfa80c4143 100644 --- a/src/Mod/PartDesign/fcgear/fcgeardialog.py +++ b/src/Mod/PartDesign/fcgear/fcgeardialog.py @@ -30,7 +30,7 @@ class GearCreationFrame(qt.QFrame): l = qt.QFormLayout(self) l.setFieldGrowthPolicy(l.ExpandingFieldsGrow) l.addRow('Number of teeth:', self.Z) - l.addRow('Modules (mm):', self.m) + l.addRow('Module (mm):', self.m) l.addRow('Pressure angle:', self.angle) l.addRow('Number of curves:', self.split) @@ -46,7 +46,7 @@ class GearDialog(qt.QDialog): l = qt.QVBoxLayout(self) l.addWidget(self.gc) l.addWidget(buttonBox) - self.setWindowTitle('Gear cration dialog') + self.setWindowTitle('Gear creation dialog') def accept(self): if FreeCAD.ActiveDocument is None: @@ -56,6 +56,10 @@ class GearDialog(qt.QDialog): self.gc.Z.value(), self.gc.angle.value(), not self.gc.split.currentIndex()) + + # Use gear to silence static analyzer complaints about unused variables (TODO: Waiting on PEP640 or similar) + False if gear.__name__ else True + FreeCADGui.SendMsgToActiveView("ViewFit") return super(GearDialog, self).accept() diff --git a/src/Mod/PartDesign/fcgear/involute.py b/src/Mod/PartDesign/fcgear/involute.py index 3add918124..d8349a972b 100644 --- a/src/Mod/PartDesign/fcgear/involute.py +++ b/src/Mod/PartDesign/fcgear/involute.py @@ -22,7 +22,7 @@ # License along with FCGear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -from math import cos, sin, pi, acos, asin, atan, sqrt +from math import cos, sin, pi, acos, atan, sqrt import sys if sys.version_info.major >= 3: diff --git a/src/Mod/PartDesign/fcgear/svggear.py b/src/Mod/PartDesign/fcgear/svggear.py index 0752290ecc..5908bd46f1 100644 --- a/src/Mod/PartDesign/fcgear/svggear.py +++ b/src/Mod/PartDesign/fcgear/svggear.py @@ -16,7 +16,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 import itertools -from math import cos, sin from involute import CreateExternalGear, rotate def makeGear(m, Z, angle): @@ -65,7 +64,7 @@ if __name__ == '__main__': dest='angle', default=20) opts, args = p.parse_args() if len(args) != 2: - p.error() + p.error("Invalid arguments") m, Z = [float(v) for v in args] print(makeGear(m, int(Z), float(opts.angle)))