From acfce7ac46c48417c7898607ae5abdae978f69d1 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <fwinkl@cern>
Date: Wed, 11 Nov 2020 15:02:59 +0100
Subject: [PATCH] GeneratorModules: enable flake8 and make code compliant

---
 Generators/GeneratorModules/CMakeLists.txt         |  2 +-
 Generators/GeneratorModules/python/EvgenAlg.py     | 14 +++++++-------
 .../GeneratorModules/python/EvgenAnalysisAlg.py    |  5 ++---
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Generators/GeneratorModules/CMakeLists.txt b/Generators/GeneratorModules/CMakeLists.txt
index 1239ed294e3..0169106379a 100644
--- a/Generators/GeneratorModules/CMakeLists.txt
+++ b/Generators/GeneratorModules/CMakeLists.txt
@@ -21,5 +21,5 @@ atlas_add_component( GeneratorModules
                      LINK_LIBRARIES GeneratorModulesLib )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 
diff --git a/Generators/GeneratorModules/python/EvgenAlg.py b/Generators/GeneratorModules/python/EvgenAlg.py
index a91051415f7..878765d65ae 100644
--- a/Generators/GeneratorModules/python/EvgenAlg.py
+++ b/Generators/GeneratorModules/python/EvgenAlg.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from AthenaPython import PyAthena
 from AthenaPython.PyAthena import StatusCode
@@ -27,8 +27,8 @@ class EvgenAlg(PyAthena.Alg):
 
 
     def initialize(self):
-        import McParticleEvent.Pythonizations
-        self.msg.debug("Initializing [%s]"% self.getName())
+        import McParticleEvent.Pythonizations  # noqa: F401
+        self.msg.debug("Initializing [%s]", self.getName())
 
         return self.genInitialize()
 
@@ -36,21 +36,21 @@ class EvgenAlg(PyAthena.Alg):
     def execute(self):
         from AthenaPython.PyAthena import McEventCollection, HepMC
 
-        self.msg.debug("Executing [%s]"% self.getName())
+        self.msg.debug("Executing [%s]", self.getName())
 
         ## Retrieve MC event collection or create a new one
         mcevts = None
         if self.evtStore.contains(McEventCollection, self.McEventKey):
-            self.msg.debug(self.McEventKey + " found before alg execution!")
+            self.msg.debug("%s found before alg execution!", self.McEventKey)
             mcevts = self.evtStore[self.McEventKey]
         else:
-            self.msg.debug("Creating " + self.McEventKey + " before alg execution!")
+            self.msg.debug("Creating %s before alg execution!", self.McEventKey)
             mcevts = McEventCollection()
             self.evtStore.record(mcevts, self.McEventKey, True, False)
         ROOT.SetOwnership(mcevts, False)
 
         if self.evtStore.contains(McEventCollection, self.McEventKey):
-            self.msg.debug(self.McEventKey + " found after alg execution!")
+            self.msg.debug("%s found after alg execution!", self.McEventKey)
 
         ## Get the first event from the MCEC, or make a new one
         evt = None
diff --git a/Generators/GeneratorModules/python/EvgenAnalysisAlg.py b/Generators/GeneratorModules/python/EvgenAnalysisAlg.py
index a504e2e5967..915380772c1 100644
--- a/Generators/GeneratorModules/python/EvgenAnalysisAlg.py
+++ b/Generators/GeneratorModules/python/EvgenAnalysisAlg.py
@@ -1,8 +1,7 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from AthenaPython import PyAthena
-from AthenaPython.PyAthena import StatusCode, McEventCollection, HepMC, CLHEP
-import McParticleEvent.Pythonizations
+import McParticleEvent.Pythonizations  # noqa: F401
 
 
 class EvgenAnalysisAlg(PyAthena.Alg):
-- 
GitLab