From 29d5f8d7caec091e59dbf6b68c17e281ae72bfd5 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <fwinkl@cern>
Date: Wed, 4 Nov 2020 14:18:06 +0100
Subject: [PATCH] tauRec: enable flake8 and fix code

---
 Reconstruction/tauRec/CMakeLists.txt           |  3 +--
 .../tauRec/python/TauAlgorithmsHolder.py       |  8 ++------
 .../tauRec/python/TauRecAODBuilder.py          | 18 +++---------------
 Reconstruction/tauRec/python/TauRecBuilder.py  |  5 -----
 .../tauRec/python/TauRecConfigured.py          |  3 +--
 .../tauRec/python/TauRecRunConfigured.py       |  3 +--
 Reconstruction/tauRec/python/TauRecRunner.py   |  8 +-------
 7 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/Reconstruction/tauRec/CMakeLists.txt b/Reconstruction/tauRec/CMakeLists.txt
index 6358a9be007a..ff32972471ce 100644
--- a/Reconstruction/tauRec/CMakeLists.txt
+++ b/Reconstruction/tauRec/CMakeLists.txt
@@ -14,6 +14,5 @@ atlas_add_component( tauRec
                      LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps CaloEvent CaloInterfaceLib CaloUtilsLib GaudiKernel InDetReadoutGeometry NavFourMom StoreGateLib TRT_ReadoutGeometry tauRecToolsLib xAODCaloEvent xAODCore xAODJet xAODPFlow xAODParticleEvent xAODTau xAODTracking )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/*.py )
-
diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
index 0868a8ec7684..acd1dd0d5bca 100644
--- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
+++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
@@ -9,8 +9,7 @@
 #@author Felix Friedrich <felix.friedrich@cern.ch>
 ################################################################################
 
-from AthenaCommon.SystemOfUnits import *
-from AthenaCommon.Constants import *
+from AthenaCommon.SystemOfUnits import GeV, mm
 from tauRec.tauRecFlags import tauFlags
 
 cached_instances = {}
@@ -287,8 +286,6 @@ def getTauVertexVariables():
     if _name in cached_instances:
         return cached_instances[_name]
 
-    from tauRec.tauRecFlags import jobproperties
-
     from tauRecTools.tauRecToolsConf import TauVertexVariables
     TauVertexVariables = TauVertexVariables(  name = _name,
                                               VertexFitter = getTauAdaptiveVertexFitter(),
@@ -559,7 +556,6 @@ def getInDetTrackSelectorToolxAOD():
 # setup up JVA tools
 # Currently not used - moved into TauRecConfigured.py and added directly to topSequence
 def setupTauJVFTool():
-    from AthenaCommon.AppMgr import ToolSvc
 
     #Configures tau track selection tool for TJVA
     """
@@ -1023,7 +1019,7 @@ def getTauVertexCorrection():
 def getParticleCache():
     #If reading from ESD we not create a cache of extrapolations to the calorimeter, so we should signify this by setting the cache key to a null string
     from RecExConfig.RecFlags import rec
-    if True == rec.doESD:
+    if rec.doESD is True:
         ParticleCache = "ParticleCaloExtension"
     else : 
         ParticleCache = ""
diff --git a/Reconstruction/tauRec/python/TauRecAODBuilder.py b/Reconstruction/tauRec/python/TauRecAODBuilder.py
index deaa3be7cd74..5b784bd697c2 100644
--- a/Reconstruction/tauRec/python/TauRecAODBuilder.py
+++ b/Reconstruction/tauRec/python/TauRecAODBuilder.py
@@ -17,17 +17,8 @@
 ################################################################################
 
 
-import os, sys, string
-
 from AthenaCommon.Logging import logging
-from AthenaCommon.SystemOfUnits import *
-from AthenaCommon.Constants import *
-from AthenaCommon.AlgSequence import AlgSequence
-from AthenaCommon.Resilience import treatException
-from AthenaCommon.Include import include
 import traceback
-
-from RecExConfig.Configured import Configured
 from TauRecConfigured import TauRecConfigured
 
 ################################################################################
@@ -89,12 +80,9 @@ class TauRecAODProcessor ( TauRecConfigured ) :
                 import TauDiscriminant.TauDiscriGetter as tauDisc
                 tauDiscTools=tauDisc.getTauDiscriminantTools(mlog)
                 if len(tauDiscTools)==0:
-                    try: import DOESNOTEXIST
-                    except Exception:
-                        mlog.error("No TauDiscriminantTools appended")
-                        traceback.print_exc()
-                        return False
-                    pass                
+                    mlog.error("No TauDiscriminantTools appended")
+                    traceback.print_stack()
+                    return False
                 tools+=tauDiscTools
                 pass
             
diff --git a/Reconstruction/tauRec/python/TauRecBuilder.py b/Reconstruction/tauRec/python/TauRecBuilder.py
index fc5db0cff396..ec0c4400d6ed 100644
--- a/Reconstruction/tauRec/python/TauRecBuilder.py
+++ b/Reconstruction/tauRec/python/TauRecBuilder.py
@@ -12,13 +12,8 @@
 #
 ################################################################################
 
-import os, sys, string
 from AthenaCommon.Logging import logging
-from AthenaCommon.SystemOfUnits import *
-from AthenaCommon.Constants import *
-from AthenaCommon.BeamFlags import jobproperties
 import traceback
-from RecExConfig.Configured import Configured
 from .TauRecConfigured import TauRecConfigured
 
 ################################################################################
diff --git a/Reconstruction/tauRec/python/TauRecConfigured.py b/Reconstruction/tauRec/python/TauRecConfigured.py
index 0e6b79a86052..d14c9781f087 100644
--- a/Reconstruction/tauRec/python/TauRecConfigured.py
+++ b/Reconstruction/tauRec/python/TauRecConfigured.py
@@ -15,7 +15,7 @@
 
 from RecExConfig.Configured import Configured
 from AthenaCommon.BeamFlags import jobproperties
-from AthenaCommon.SystemOfUnits import *
+from AthenaCommon.SystemOfUnits import mm
 
 ################################################################################
 ## @class TauRecConfigured
@@ -34,7 +34,6 @@ class TauRecConfigured ( Configured ) :
         from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool
         # add calo cell finalizer tool
         TauCellContainerFinalizer = CaloCellContainerFinalizerTool(name='tauRec_tauPi0CellContainerFinalizer')
-        from AthenaCommon.AppMgr import ToolSvc
 
         self._TauProcessorAlgHandle = TauProcessorAlg ( name=self.name+'Alg',
                                                         Key_jetInputContainer=tauFlags.tauRecSeedJetCollection(),
diff --git a/Reconstruction/tauRec/python/TauRecRunConfigured.py b/Reconstruction/tauRec/python/TauRecRunConfigured.py
index a8a6415e0f36..7927097b9af0 100644
--- a/Reconstruction/tauRec/python/TauRecRunConfigured.py
+++ b/Reconstruction/tauRec/python/TauRecRunConfigured.py
@@ -27,8 +27,7 @@ class TauRecRunConfigured ( Configured ) :
     def __init__(self, name = "TauRecRunConfigured", msglevel=3, ignoreExistingDataObject=True) :
         self.name = name
         self.msglevel = msglevel
-        from tauRec.tauRecConf import TauRunnerAlg 
-        from tauRec.tauRecFlags import tauFlags
+        from tauRec.tauRecConf import TauRunnerAlg
         self._TauRunnerAlgHandle = TauRunnerAlg ( name=self.name+'Alg', 
                                                   Key_tauInputContainer="tmp_TauJets",
                                                   Key_Pi0ClusterInputContainer="TauPi0Clusters",
diff --git a/Reconstruction/tauRec/python/TauRecRunner.py b/Reconstruction/tauRec/python/TauRecRunner.py
index f87386826433..91e3fa5f59c9 100644
--- a/Reconstruction/tauRec/python/TauRecRunner.py
+++ b/Reconstruction/tauRec/python/TauRecRunner.py
@@ -12,13 +12,8 @@
 #
 ################################################################################
 
-import os, sys, string
 from AthenaCommon.Logging import logging
-from AthenaCommon.SystemOfUnits import *
-from AthenaCommon.Constants import *
 from AthenaCommon.BeamFlags import jobproperties
-import traceback
-from RecExConfig.Configured import Configured
 from .TauRecRunConfigured import TauRecRunConfigured
 
 ################################################################################
@@ -37,8 +32,7 @@ class TauRecRunner ( TauRecRunConfigured ) :
     def configure(self):
         mlog = logging.getLogger ('TauRecRunner.py::configure:')
         mlog.info('entering')
-                
-        from RecExConfig.RecFlags import rec                
+
         import tauRec.TauAlgorithmsHolder as taualgs        
         from tauRec.tauRecFlags import tauFlags                
         
-- 
GitLab