From 6b11d45e7a061d4af37fec221b8f60aec994d70f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 9 Feb 2021 19:39:21 -0600 Subject: [PATCH] LGTM: Minor fixes to FreeCADApp.py LGTM flagged several redundant imports, and was confused by the else clause of one loop. This commit removes those imports, and because of the loop's construction, removes the else entirely and lets the loop fall through to the error state if it fails to find what it's looking for. --- src/App/FreeCADInit.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index c5f5a16670..96dd111f41 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -34,18 +34,17 @@ def removeFromPath(module_name): """removes the module from the sys.path. The entry point for imports will therefore always be FreeCAD. eg.: from FreeCAD.Module.submodule import function""" - import sys, os + import sys paths = sys.path for path in paths: if module_name in path: sys.path.remove(path) return - else: - Wrn(module_name + " not found in sys.path\n") + Wrn(module_name + " not found in sys.path\n") def setupSearchPaths(PathExtension): # DLL resolution in Python 3.8 on Windows has changed - import sys, os + import sys if sys.platform == 'win32' and hasattr(os, "add_dll_directory"): if "FREECAD_LIBPACK_BIN" in os.environ: os.add_dll_directory(os.environ["FREECAD_LIBPACK_BIN"]) @@ -253,7 +252,7 @@ App.__unit_test__ = [] Log ('Init: starting App::FreeCADInit.py\n') try: - import sys,os,traceback,io,inspect + import sys,os,traceback,inspect from datetime import datetime except ImportError: FreeCAD.Console.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n") @@ -632,7 +631,6 @@ FreeCAD.Logger = FCADLogger # init every application by importing Init.py try: - import traceback InitApplications() except Exception as e: Err('Error in InitApplications ' + str(e) + '\n')