diff --git a/Simulation/G4Atlas/G4AtlasApps/CMakeLists.txt b/Simulation/G4Atlas/G4AtlasApps/CMakeLists.txt
index c4b7a21c5e2a2597e591ccba020e683f55af4014..b4e27489070569895e1282c2ad53ac813f681308 100644
--- a/Simulation/G4Atlas/G4AtlasApps/CMakeLists.txt
+++ b/Simulation/G4Atlas/G4AtlasApps/CMakeLists.txt
@@ -1,14 +1,9 @@
-################################################################################
-# Package: G4AtlasApps
-################################################################################
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 # Declare the package name:
 atlas_subdir( G4AtlasApps )
 
-# External dependencies:
-find_package( COOL COMPONENTS CoolKernel )
-find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
-
+# Tests in the package:
 atlas_add_test(test_AtlasG4_tf_configuration
                SCRIPT test/test_AtlasG4_tf_configuration.py
                PROPERTIES TIMEOUT 300
@@ -27,6 +22,6 @@ if( NOT SIMULATIONBASE )
 endif()
 
 # 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/Simulation/G4Atlas/G4AtlasApps/python/AtlasCosmicTrackRecordJob.py b/Simulation/G4Atlas/G4AtlasApps/python/AtlasCosmicTrackRecordJob.py
index 90cf182ca2e4c61a225c85d7053214b9bd689b7f..bc33031e5bac176148a8a5c727d95ea6247e638c 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/AtlasCosmicTrackRecordJob.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/AtlasCosmicTrackRecordJob.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 ## @file AtlasCosmicTrackRecordJob.py
 ## @brief py-module to configure the Athena AppMgr for cosmic track record reading jobs
@@ -6,7 +6,7 @@
 ###############################################################
 
 def _setupAtlasCosmicTrackRecordJob():
-    import AthenaCommon.AtlasUnixStandardJob
+    import AthenaCommon.AtlasUnixStandardJob  # noqa: F401
     from AthenaCommon.AppMgr import theApp
     from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/AtlasG4Eng.py b/Simulation/G4Atlas/G4AtlasApps/python/AtlasG4Eng.py
index c0e4dac47bd5e6b4442097111d589c89ce3962c9..74d811afe91098094dbcd45bd2f0126169a95add 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/AtlasG4Eng.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/AtlasG4Eng.py
@@ -10,11 +10,8 @@ The basic elements and materials are also defined here. If custom materials are
 needed, they can be produced using the template atlas_materials.py.
 """
 
-from __future__ import print_function
-
 __author__ = "A. Dell`Acqua, M. Gallas"
 
-from AthenaCommon.SystemOfUnits import *
 from AthenaCommon import Logging
 from time import time
 import os, os.path, string, sys
@@ -76,7 +73,7 @@ class G4AtlasEngine:
         """
         if G4AtlasEngine._NumInstances > 0:
             msg = 'There is already an instance of the G4AtlasEngine class -- try to use it!'
-            G4AtlasEngine.log.error('G4AtlasEngine: ' + msg)
+            G4AtlasEngine.log.error('G4AtlasEngine: %s', msg)
             raise RuntimeError('PyG4Atlas: G4AtlasEngine: __init__(): Attempted multiple instantiation')
 
         ## Init dictionaries and lists
@@ -123,7 +120,7 @@ class G4AtlasEngine:
 
 
     def setUseISF(self, useISF) :
-        G4AtlasEngine.log.info('setting useISF to %s' % useISF)
+        G4AtlasEngine.log.info('setting useISF to %s', useISF)
         self.useISF = useISF
 
     def _init_G4(self):
@@ -173,26 +170,26 @@ class G4AtlasEngine:
         def _run_init_stage(name):
             # TODO: Set self.init_status at each sub-step and write that out in _run_init_callbacks
             self.init_status = "preInit" + name
-            G4AtlasEngine.log.debug("G4AtlasEngine:init stage " + self.init_status)
+            G4AtlasEngine.log.debug("G4AtlasEngine:init stage %s", self.init_status)
             _run_init_callbacks(self.init_status)
             self.init_status = "init" + name
-            G4AtlasEngine.log.debug("G4AtlasEngine:init stage " + self.init_status)
+            G4AtlasEngine.log.debug("G4AtlasEngine:init stage %s", self.init_status)
             getattr(self, "_init_" + name).__call__()
             self.init_status = "postInit" + name
-            G4AtlasEngine.log.debug("G4AtlasEngine:init stage " + self.init_status)
+            G4AtlasEngine.log.debug("G4AtlasEngine:init stage %s", self.init_status)
             _run_init_callbacks(self.init_status)
 
         _run_init_stage("G4")
 
         self.init_status = "postInit"
-        G4AtlasEngine.log.debug("G4AtlasEngine:init stage " + self.init_status)
+        G4AtlasEngine.log.debug("G4AtlasEngine:init stage %s", self.init_status)
         _run_init_callbacks(self.init_status)
 
         ## Check that all the callbacks were indeed called, and warn otherwise
         num_reg_callbacks = sum(len(cblist) for cblist in simFlags.InitFunctions.get_Value().values())
         if G4AtlasEngine._callback_counter != num_reg_callbacks:
-            G4AtlasEngine.log.warning("G4AtlasEngine: mismatch in num of callbacks regd/called = %d/%d" %
-                                      (num_reg_callbacks, G4AtlasEngine._callback_counter))
+            G4AtlasEngine.log.warning("G4AtlasEngine: mismatch in num of callbacks regd/called = %d/%d",
+                                      num_reg_callbacks, G4AtlasEngine._callback_counter)
 
         G4AtlasEngine._app_profiler('_init_Simulation')
 
@@ -206,13 +203,13 @@ class G4AtlasEngine:
         if dict_name and dict_name not in G4AtlasEngine.List_LoadedDict:
             try:
                 cppyy.loadDict(dict_name)
-            except:
+            except Exception:
                 print ("Unexpected error:", sys.exc_info(),'\n')
                 print ('ROOT5 migration problem: ', dict_name)
             try:
                 G4AtlasEngine.List_LoadedDict.append(dict_name)
-                G4AtlasEngine.log.debug(' G4AtlasEngine:load_Dict: %s loaded' % dict_name)
-            except:
+                G4AtlasEngine.log.debug(' G4AtlasEngine:load_Dict: %s loaded', dict_name)
+            except Exception:
                 raise RuntimeError('Dict %s can not be found' % dict_name)
 
 
@@ -301,7 +298,7 @@ class G4AtlasEngine:
             See the flag 'simFlags.EventFilter'
             """
             if self._Built:
-                G4AtlasEngine.log.debug('menu_EventFilter._build: init EventFilter manipulators already done\n%s' % self.getFilterStatus())
+                G4AtlasEngine.log.debug('menu_EventFilter._build: init EventFilter manipulators already done\n%s', self.getFilterStatus())
                 return
             self._Built = True
 
@@ -318,7 +315,7 @@ class G4AtlasEngine:
                     fobj.switchOff()
 
             G4AtlasEngine.Dict['EventFilters'] = self
-            G4AtlasEngine.log.debug('menu_EventFilter._build: init EventFilter manipulators\n%s' % self.getFilterStatus())
+            G4AtlasEngine.log.debug('menu_EventFilter._build: init EventFilter manipulators\n%s', self.getFilterStatus())
 
 
 
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/DetConfigurator.py b/Simulation/G4Atlas/G4AtlasApps/python/DetConfigurator.py
index e123948d50dc3049f03b26bd56c7e6b0a82b2258..8d596c7e529cee35d0f1bde832f731edfb8ff95c 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/DetConfigurator.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/DetConfigurator.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
 from G4AtlasApps import AtlasG4Eng
 class DetConfigurator:
     """ DetConfigurator is a hook for the specific sub-detector configuration.
@@ -40,7 +42,7 @@ class DetConfigurator:
             self.build(self.Mode)
             self._Built = True
         else:
-            AtlasG4Eng.G4Eng.log.info(' DetConfigurator: with name '+self.Name+ ' is already in the Dict_DetConfig: please use it!')
+            AtlasG4Eng.G4Eng.log.info(' DetConfigurator: with name %s is already in the Dict_DetConfig: please use it!', self.Name)
 
 
     def build(self,mode):
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_Metadata.py b/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_Metadata.py
index a1007db4de7c1c67a6f7814c9c2b190da19f1393..083431c48e41b84cee16b0b3ba7e9480590563ce 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_Metadata.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_Metadata.py
@@ -1,9 +1,9 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 ### This module contains functions which may need to peek at the input file metadata
 
 ## Get the logger
-from AthenaCommon.Logging import *
+from AthenaCommon.Logging import logging
 simMDlog = logging.getLogger('Sim_Metadata')
 
 
@@ -20,7 +20,7 @@ def get_metadata(mode='lite'):
                 metadata = read_metadata(input_file, mode = mode)
                 metadata = metadata[input_file]  # promote all keys one level up
                 return metadata
-            except:
+            except Exception:
                 simMDlog.warning("MetaReader failed to open %s", athenaCommonFlags.PoolEvgenInput()[0])
     else:
         simMDlog.info("G4ATLAS_SKIPFILEPEEK environment variable present, so skipping all input file peeking.")
@@ -60,7 +60,7 @@ def patch_mc_channel_numberMetadata(addToFile=True):
             if addToFile:
                 simMDlog.info('Adding mc_channel_number to /TagInfo: %s', str(mc_channel_number))
                 # Initialize tag info management
-                import EventInfoMgt.EventInfoMgtInit
+                import EventInfoMgt.EventInfoMgtInit  # noqa: F401
                 from AthenaCommon.AppMgr import ServiceMgr
                 ServiceMgr.TagInfoMgr.ExtraTagValuePairs.update({"mc_channel_number": str(mc_channel_number)})
         return mc_channel_number
@@ -186,7 +186,6 @@ def createSimulationParametersMetadata():
     ## Set run numbers
     minrunnum = 0
     maxrunnum = 2147483647  # MAX
-    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
     from G4AtlasApps.SimFlags import simFlags
     if hasattr(simFlags, 'RunNumber') and simFlags.RunNumber.statusOn:
        minrunnum = simFlags.RunNumber()
@@ -200,7 +199,7 @@ def createSimulationParametersMetadata():
             raise Exception('IllegalRunNumber')
     else:
         simMDlog.info('Skipping runNumbers setting - would need to set simFlags.RunNumber for this.')
-    simMDlog.info("Using the following runNumbers range for MetaData IOV: ("+str(minrunnum)+","+str(maxrunnum)+").")
+    simMDlog.info("Using the following runNumbers range for MetaData IOV: (%d,%d).", minrunnum, maxrunnum)
     dbFiller.setBeginRun(minrunnum)
     dbFiller.setEndRun(maxrunnum)
 
@@ -212,7 +211,7 @@ def createSimulationParametersMetadata():
     dbFiller.genSimDb()
     folder = "/Simulation/Parameters"
     dbConnection = "sqlite://;schema=SimParams.db;dbname=SIMPARAM"
-    import IOVDbSvc.IOVDb
+    import IOVDbSvc.IOVDb  # noqa: F401
     from AthenaCommon.AppMgr import ServiceMgr
     ServiceMgr.IOVDbSvc.Folders += [ folder + "<dbConnection>" + dbConnection + "</dbConnection>" ]
     ServiceMgr.IOVDbSvc.FoldersToMetaData += [folder]
@@ -224,7 +223,6 @@ def createTBSimulationParametersMetadata():
     # Set run numbers
     minrunnum = 0
     maxrunnum = 2147483647 # MAX
-    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
     from G4AtlasApps.SimFlags import simFlags
     if hasattr(simFlags, 'RunNumber') and simFlags.RunNumber.statusOn:
        minrunnum = simFlags.RunNumber()
@@ -238,7 +236,7 @@ def createTBSimulationParametersMetadata():
             raise Exception('IllegalRunNumber')
     else:
         simMDlog.info('Skipping runNumbers setting - would need to set simFlags.RunNumber for this.')
-    simMDlog.info("Using the following runNumbers range for MetaData IOV: ("+str(minrunnum)+","+str(maxrunnum)+").")
+    simMDlog.info("Using the following runNumbers range for MetaData IOV: (%d,%d).", minrunnum, maxrunnum)
     dbFiller.setBeginRun(minrunnum)
     dbFiller.setEndRun(maxrunnum)
 
@@ -250,7 +248,7 @@ def createTBSimulationParametersMetadata():
     dbFiller.genSimDb()
     folder = "/Simulation/Parameters"
     dbConnection = "sqlite://;schema=SimParams.db;dbname=SIMPARAM"
-    import IOVDbSvc.IOVDb
+    import IOVDbSvc.IOVDb  # noqa: F401
     from AthenaCommon.AppMgr import ServiceMgr
     ServiceMgr.IOVDbSvc.Folders += [ folder + "<dbConnection>" + dbConnection + "</dbConnection>" ]
     ServiceMgr.IOVDbSvc.FoldersToMetaData += [folder]
@@ -265,7 +263,7 @@ def configureRunNumberOverrides():
     from G4AtlasApps.SimFlags import simFlags
     if hasattr(simFlags, "RunNumber") and simFlags.RunNumber.statusOn:
         myRunNumber = simFlags.RunNumber.get_Value()
-        simMDlog.info('Found run number %d in sim flags.' % myRunNumber)
+        simMDlog.info('Found run number %d in sim flags.', myRunNumber)
         ## Set event selector details based on evgen metadata
 
         ######update the run/event info for each event
@@ -292,7 +290,7 @@ def configureRunNumberOverrides():
           from RunDependentSimComps.RunDMCFlags import runDMCFlags
           myInitialTimeStamp = runDMCFlags.RunToTimestampDict.getTimestampForRun(myRunNumber)
           #print "FOUND TIMESTAMP ", str(myInitialTimeStamp)
-        except:
+        except Exception:
           myInitialTimeStamp = 1
         ServiceMgr.EvtIdModifierSvc.add_modifier(run_nbr=myRunNumber, lbk_nbr=myFirstLB, time_stamp=myInitialTimeStamp, nevts=totalNumber)
         if hasattr(ServiceMgr.EventSelector,'OverrideRunNumberFromInput'): ServiceMgr.EventSelector.OverrideRunNumberFromInput = True
@@ -300,7 +298,7 @@ def configureRunNumberOverrides():
         # Get evgen run number and lumi block
         if len(metadata_lite['runNumbers']) > 0:
             myRunNumber = metadata_lite['runNumbers'][0]
-            simMDlog.info('Found runNumbers %d in hits file metadata.'% myRunNumber)
+            simMDlog.info('Found runNumbers %d in hits file metadata.', myRunNumber)
         else:
             simMDlog.warning('Failed to find runNumbers in hits file metadata.')
         if metadata_lite['lumiBlockNumbers']:
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_MetadataNew.py b/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_MetadataNew.py
index 71167e0004198ee5758f7067cd07bf7d165bfa37..f075b62cf8440aee82b94af16c38f39da67b2ae6 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_MetadataNew.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/G4Atlas_MetadataNew.py
@@ -1,9 +1,9 @@
-# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 ### This module contains functions which may need to peek at the input file metadata
 
 ## Get the logger
-from AthenaCommon.Logging import *
+from AthenaCommon.Logging import logging
 simMDlog = logging.getLogger('Sim_Metadata')
 
 def fillAtlasMetadata(ConfigFlags, dbFiller):
@@ -26,7 +26,7 @@ def fillAtlasMetadata(ConfigFlags, dbFiller):
 
     #---------  
     ## Simulated detector flags: add each enabled detector to the simulatedDetectors list
-    from AthenaCommon.DetFlags import DetFlags
+    from AthenaCommon.DetFlags import DetFlags  # noqa: F401
     simDets = []
     for det in ['Pixel','SCT','TRT','BCM','Lucid','ZDC','ALFA','AFP','FwdRegion','LAr','HGTD','Tile','MDT','CSC','TGC','RPC','MM','sTGC','Truth','LVL1']:
         attrname = "Detector.Geometry"+det
@@ -37,7 +37,7 @@ def fillAtlasMetadata(ConfigFlags, dbFiller):
         else:
             simMDlog.info("No flag called '%s' found in ConfigFlags", attrname)
 
-    simMDlog.info("Setting 'SimulatedDetectors' = %s" % repr(simDets))
+    simMDlog.info("Setting 'SimulatedDetectors' = %r", simDets)
     dbFiller.addSimParam('SimulatedDetectors', repr(simDets))
 
     ## Hard-coded simulation hit file magic number (for major changes)
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py
index 019c1dc84f375804fdb53ddc90e66530ba05f3d3..9838c52bbbfb8954ee8862ce74996daf792c9625 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """ Geant4 simulation Python facilities for the ATLAS experiment.
 
@@ -10,15 +10,7 @@
 
 __author__ = 'A. Dell`Acqua, M. Gallas, A. Buckley'
 
-import os, os.path, string, sys
-from time import time
-from GaudiPython import PyAlgorithm
-from AthenaCommon import Constants, Logging, SystemOfUnits
 from AthenaCommon.AppMgr import theApp
-from AthenaCommon.Include import include
-import cppyy
-
-from G4AtlasApps import AtlasG4Eng
 
 from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps
 if concurrencyProps.ConcurrencyFlags.NumThreads() > 0:
@@ -78,16 +70,16 @@ class _PyG4AtlasComp(PyG4Atlas_base):
             AtlasG4Eng.G4Eng.log.info('Configuring CTB H8 (2004) test beam')
             dummy = CtbSim()
         elif "simu_skeleton" not in AtlasG4Eng.G4Eng.Dict:
-            AtlasG4Eng.G4Eng.log.error('No sim skeleton registered by time of %s construction: STOP!!' % self.name())
+            AtlasG4Eng.G4Eng.log.error('No sim skeleton registered by time of %s construction: STOP!!', self.name())
             raise ValueError('Unknown sim setup: STOP')
 
         ## Import sim module if requested
         # TODO: is this ever used?
         if self.sim_module:
-            AtlasG4Eng.G4Eng.log.info("The kernel simulation Python module which describes the simulation is: %s" % self.sim_module)
+            AtlasG4Eng.G4Eng.log.info("The kernel simulation Python module which describes the simulation is: %s", self.sim_module)
             try:
                 __import__(self.sim_module, globals(), locals())
-            except:
+            except Exception:
                 AtlasG4Eng.G4Eng.log.fatal("The kernel simulation Python module '%s' was not found!" % self.sim_module)
                 raise RuntimeError('PyG4Atlas: %s: initialize()' % self.name())
 
@@ -102,12 +94,11 @@ class _PyG4AtlasComp(PyG4Atlas_base):
         import AtlasG4Eng
         from time import gmtime, strftime
         timestr = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
-        AtlasG4Eng.G4Eng.log.info('%s starting at (UTC): %s' % (self.name(), timestr))
+        AtlasG4Eng.G4Eng.log.info('%s starting at (UTC): %s', self.name(), timestr)
         AtlasG4Eng.G4Eng._app_profiler('%s begin of initialize' % self.name())
         AtlasG4Eng.G4Eng.Dict['simu_skeleton']._do_All()
         AtlasG4Eng.G4Eng._init_Simulation()
 
-        from G4AtlasApps.SimFlags import simFlags
         AtlasG4Eng.G4Eng._app_profiler('%s end of initialize' % self.name())
 
         from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
@@ -120,7 +111,7 @@ class _PyG4AtlasComp(PyG4Atlas_base):
         AtlasG4Eng.G4Eng._app_profiler('%s at finalize  ' % self.name())
         from time import gmtime, strftime
         timestr = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
-        AtlasG4Eng.G4Eng.log.info('%s ending at (UTC): %s'  % (self.name(), timestr))
+        AtlasG4Eng.G4Eng.log.info('%s ending at (UTC): %s', self.name(), timestr)
         return True
 
 if is_hive:
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py
index 273b7aec934f54b5abd8253d4f803c0d37b68d0d..1e49626547f8ecf29a3ccbd6e1d4ba258db89397 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py
@@ -1,18 +1,15 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """
 Main configuration module for the full ATLAS simulations
 """
 
-import math
-from AthenaCommon import PhysicalConstants
 from AthenaCommon.AppMgr import theApp
 from AthenaCommon.Include import include
 from AthenaCommon.JobProperties import jobproperties
 from AthenaCommon.DetFlags import DetFlags
-from AthenaCommon.BeamFlags import jobproperties
 
-import PyG4Atlas, AtlasG4Eng
+import AtlasG4Eng
 from SimSkeleton import SimSkeleton
 
 
@@ -27,7 +24,7 @@ class AtlasSimSkeleton(SimSkeleton):
             AtlasG4Eng.G4Eng.Dict['simu_skeleton'] = self
             AtlasG4Eng.G4Eng.Name = "ATLAS_G4Sim"
         else:
-            AtlasG4Eng.G4Eng.log.warning('AtlasSimSkeleton.__init__ :: the simulation already has a skeleton.' +
+            AtlasG4Eng.G4Eng.log.warning('AtlasSimSkeleton.__init__ :: the simulation already has a skeleton.'
                                                'You can find it in the G4AtlasEng.G4Eng.Dict()')
 
 
@@ -126,7 +123,7 @@ class AtlasSimSkeleton(SimSkeleton):
            frozen showers, etc
         """
         AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_external :: starting')
-        from AthenaCommon.AppMgr import ToolSvc,ServiceMgr
+        from AthenaCommon.AppMgr import ServiceMgr
         from Geo2G4.Geo2G4Conf import Geo2G4Svc
         geo2G4Svc = Geo2G4Svc()
         theApp.CreateSvc += ["Geo2G4Svc"]
@@ -145,7 +142,7 @@ class AtlasSimSkeleton(SimSkeleton):
         ## TODO: Tidy imports etc.
         from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
         from AthenaCommon.GlobalFlags import jobproperties
-        from AtlasGeoModel import SetGeometryVersion
+        from AtlasGeoModel import SetGeometryVersion  # noqa: F401
 
         ## Forward Region Twiss files - needed before geometry setup!
         if simFlags.ForwardDetectors.statusOn:
@@ -154,13 +151,12 @@ class AtlasSimSkeleton(SimSkeleton):
                 from AthenaCommon.AppMgr import ToolSvc
                 ToolSvc += getPublicTool("ForwardRegionProperties")
 
-        from AtlasGeoModel import GeoModelInit
-        from AtlasGeoModel import SimEnvelopes
-        from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
+        from AtlasGeoModel import GeoModelInit  # noqa: F401
+        from AtlasGeoModel import SimEnvelopes  # noqa: F401
         gms = GeoModelSvc()
         ## Cosmics GeoModel tweaks
         if jobproperties.Beam.beamType() == 'cosmics' or \
-           (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ):
+           (simFlags.CavernBG.statusOn and 'Signal' not in simFlags.CavernBG.get_Value() ):
             from CavernInfraGeoModel.CavernInfraGeoModelConf import CavernInfraDetectorTool
             gms.DetectorTools += [ CavernInfraDetectorTool() ]
         ## Protects GeoModelSvc in the simulation from the AlignCallbacks
@@ -176,12 +172,12 @@ class AtlasSimSkeleton(SimSkeleton):
             from AGDD2GeoSvc.AGDD2GeoSvcConf import AGDDtoGeoSvc
             AGDD2Geo = AGDDtoGeoSvc()
             from AthenaCommon import CfgGetter
-            if not "MuonAGDDTool/MuonSpectrometer" in AGDD2Geo.Builders:
+            if "MuonAGDDTool/MuonSpectrometer" not in AGDD2Geo.Builders:
                 ToolSvc += CfgGetter.getPublicTool("MuonSpectrometer", checkType=True)
                 AGDD2Geo.Builders += ["MuonAGDDTool/MuonSpectrometer"]
             from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags
             if (MuonGeometryFlags.hasSTGC() and MuonGeometryFlags.hasMM()):
-                if not "NSWAGDDTool/NewSmallWheel" in AGDD2Geo.Builders:
+                if "NSWAGDDTool/NewSmallWheel" not in AGDD2Geo.Builders:
                     ToolSvc += CfgGetter.getPublicTool("NewSmallWheel", checkType=True)
                     AGDD2Geo.Builders += ["NSWAGDDTool/NewSmallWheel"]
             theApp.CreateSvc += ["AGDDtoGeoSvc"]
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py
index 8b002ebe37e92a58c65be0f23acd4995df61975a..35be62627fed5ef8a646ec3d986adb096553a9f7 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """
 Main configuration module for the ATLAS test-beams
@@ -11,15 +11,12 @@ LAr  standalone test beams at H6
 __author__ = 'M. Gallas'
 
 
-import math
-from AthenaCommon               import PhysicalConstants
 from AthenaCommon.AppMgr        import theApp
 from AthenaCommon.Include       import include
 from AthenaCommon.GlobalFlags   import globalflags
 from AthenaCommon.DetFlags      import DetFlags
 from AthenaCommon.JobProperties import jobproperties
-from AthenaCommon.BeamFlags     import jobproperties
-import PyG4Atlas, AtlasG4Eng
+import AtlasG4Eng
 from SimSkeleton import SimSkeleton
 
 
@@ -58,12 +55,12 @@ class CtbSim(TBSimSkeleton):
         ATLAS Combined Test Beam (2004)
     """
     def __init__(self):
-        if not(AtlasG4Eng.G4Eng.Dict.has_key('simu_skeleton')):
+        if 'simu_skeleton' not in AtlasG4Eng.G4Eng.Dict:
             AtlasG4Eng.G4Eng.Dict['simu_skeleton']=self
             AtlasG4Eng.G4Eng.Name="CTB_G4Sim"         # assigns a name
         else:
-            AtlasG4Eng.G4Eng.log.warning(' SimSkeleton: the simulation '+\
-            'has already a skeleton, you can find it in the '+\
+            AtlasG4Eng.G4Eng.log.warning(' SimSkeleton: the simulation '
+            'has already a skeleton, you can find it in the '
             'G4AtlasEng.G4Eng.Dict()')
 
     @classmethod
@@ -95,16 +92,16 @@ class CtbSim(TBSimSkeleton):
         if (simFlags.BeamConditions.statusOn and
             simFlags.BeamConditions.get_Value()):
                 try:
-                    AtlasG4Eng.G4Eng.log.info(' SimCtbKernel: '+\
-                           ' loading CTB beam-conditions from the'+\
+                    AtlasG4Eng.G4Eng.log.info(' SimCtbKernel: '
+                           ' loading CTB beam-conditions from the'
                            ' CTB run-condition file !!')
-                    BeamCond=__import__(modulepath,globals(),locals(),prepath).BeamCond
+                    BeamCond=__import__(modulepath,globals(),locals(),prepath).BeamCond  # noqa: F821 (broken?)
                     beam_cond_obj=BeamCond.retrieve_Run(simFlags.RunNumber.get_Value())
                     beam_cond_obj._map()
-                except:
-                    AtlasG4Eng.G4Eng.log.warning(' SimCtbKernel: '+
-                    'No particular beam conditions found for the run '+\
-                    str(simFlags.RunNumber.get_Value()))
+                except Exception:
+                    AtlasG4Eng.G4Eng.log.warning(' SimCtbKernel: '
+                    'No particular beam conditions found for the run %s',
+                    simFlags.RunNumber.get_Value())
         # - switch off non-existing detectors
         DetFlags.FCal_setOff()
         DetFlags.HEC_setOff()
@@ -173,8 +170,7 @@ class CtbSim(TBSimSkeleton):
     def _do_external(self):
         """ Place to handle the external services: GeoModel, CondDB, etc.
         """
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'starting')
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external starting')
         from AthenaCommon.AppMgr import ServiceMgr
         from Geo2G4.Geo2G4Conf import Geo2G4Svc
         Geo2G4Svc=Geo2G4Svc()
@@ -184,7 +180,7 @@ class CtbSim(TBSimSkeleton):
         Geo2G4Svc.GetTopTransform = False
 
         #--- GeoModel stuff ----------------------------------------------------
-        from AtlasGeoModel import SetGeometryVersion
+        from AtlasGeoModel import SetGeometryVersion  # noqa: F401
 
         from AthenaCommon.Configurable import Configurable
         if Configurable.allConfigurables.get('GeoModelSvc'):
@@ -201,7 +197,7 @@ class CtbSim(TBSimSkeleton):
         elif(simFlags.GeoModelTileVersion.get_Value()=='TileTB-3B3EB-00'):
             GeoModelSvc.TileVersionOverride='TileTB-3B3EB-00'
 
-        from AtlasGeoModel import GeoModelInit
+        from AtlasGeoModel import GeoModelInit  # noqa: F401
         if(DetFlags.Calo_on()):
             # Common for the Calo
             include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" )
@@ -230,8 +226,8 @@ class CtbSim(TBSimSkeleton):
         from AthenaCommon.AppMgr import ServiceMgr
         ServiceMgr += getService('DetectorGeometrySvc')
         ServiceMgr += getService('PhysicsListSvc')
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'done')
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external done')
+
 
 #--- Tile TB 2000-2003  ------------------------------------------------
 class Tile2000_2003(TBSimSkeleton):
@@ -242,12 +238,12 @@ class Tile2000_2003(TBSimSkeleton):
 
     """
     def __init__(self):
-        if not(AtlasG4Eng.G4Eng.Dict.has_key('simu_skeleton')):
+        if 'simu_skeleton' not in AtlasG4Eng.G4Eng.Dict:
             AtlasG4Eng.G4Eng.Dict['simu_skeleton']=self
             AtlasG4Eng.G4Eng.Name="Tile2000_2003"  # assigns a name
         else:
-            G4AtlasEngine.log.warning(' SimSkeleton: the simulation '+\
-            'has already a skeleton, you can find it in the '+\
+            AtlasG4Eng.G4Eng.log.warning(' SimSkeleton: the simulation '
+            'has already a skeleton, you can find it in the '
             'G4AtlasEng.G4Eng.Dict()')
 
     @classmethod
@@ -320,8 +316,7 @@ class Tile2000_2003(TBSimSkeleton):
     def _do_external(self):
         """ Place to handle the external services: GeoModel, CondDB, etc.
         """
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'starting')
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external starting')
         from AthenaCommon.AppMgr import ServiceMgr
         from Geo2G4.Geo2G4Conf import Geo2G4Svc
         Geo2G4Svc=Geo2G4Svc()
@@ -329,7 +324,7 @@ class Tile2000_2003(TBSimSkeleton):
         ServiceMgr +=Geo2G4Svc
         Geo2G4Svc.GetTopTransform = False
 
-        from AtlasGeoModel import SetGeometryVersion
+        from AtlasGeoModel import SetGeometryVersion  # noqa: F401
         from AthenaCommon.Configurable import Configurable
         if Configurable.allConfigurables.get('GeoModelSvc'):
             GeoModelSvc=Configurable.allConfigurables.get('GeoModelSvc')
@@ -351,7 +346,7 @@ class Tile2000_2003(TBSimSkeleton):
             # 5 Barrels
             GeoModelSvc.TileVersionOverride='TileTB-5B-00'
 
-        from AtlasGeoModel import GeoModelInit
+        from AtlasGeoModel import GeoModelInit  # noqa: F401
         if(DetFlags.Calo_on()):
             # Common for the Calo
             include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" )
@@ -378,8 +373,8 @@ class Tile2000_2003(TBSimSkeleton):
         from AthenaCommon.AppMgr import ServiceMgr
         ServiceMgr += getService('DetectorGeometrySvc')
         ServiceMgr += getService('PhysicsListSvc')
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'done')
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external done')
+
 
 #--- LAr TB 2002-2004  ------------------------------------------------
 class LArH6_TB(TBSimSkeleton):
@@ -388,12 +383,12 @@ class LArH6_TB(TBSimSkeleton):
 
     """
     def __init__(self):
-        if not(AtlasG4Eng.G4Eng.Dict.has_key('simu_skeleton')):
+        if 'simu_skeleton' not in AtlasG4Eng.G4Eng.Dict:
             AtlasG4Eng.G4Eng.Dict['simu_skeleton']=self
             AtlasG4Eng.G4Eng.Name="LArH6"         # assigns a name
         else:
-            G4AtlasEngine.log.warning(' SimSkeleton: the simulation '+\
-            'has already a skeleton, you can find it in the '+\
+            AtlasG4Eng.G4Eng.log.warning(' SimSkeleton: the simulation '
+            'has already a skeleton, you can find it in the '
             'G4AtlasEng.G4Eng.Dict()')
 
     @classmethod
@@ -473,11 +468,7 @@ class LArH6_TB(TBSimSkeleton):
     def _do_external(self):
         """ Place to handle the external services: GeoModel, CondDB, etc.
         """
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'starting')
-
-       #from LArH6Detectors import Det_Layouts
-        from tbLArH6_calo import Det_Layouts
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external starting')
 
         from AthenaCommon.AppMgr import ServiceMgr
         from Geo2G4.Geo2G4Conf import Geo2G4Svc
@@ -488,8 +479,8 @@ class LArH6_TB(TBSimSkeleton):
         Geo2G4Svc.GetTopTransform = False
 
         #--- GeoModel stuff ----------------------------------------------------
-        from AtlasGeoModel import SetGeometryVersion
-        from AtlasGeoModel import GeoModelInit
+        from AtlasGeoModel import SetGeometryVersion  # noqa: F401
+        from AtlasGeoModel import GeoModelInit  # noqa: F401
 
         from AthenaCommon.Configurable import Configurable
         if Configurable.allConfigurables.get('GeoModelSvc'):
@@ -508,8 +499,7 @@ class LArH6_TB(TBSimSkeleton):
         from AthenaCommon.AppMgr import ServiceMgr
         ServiceMgr += getService('DetectorGeometrySvc')
         ServiceMgr += getService('PhysicsListSvc')
-        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external '+\
-                                       'done')
+        AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_external done')
 
         # mgallas do more here: this is not yet supported
 
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py
index af5b6415ac832a16df2da55f54680b91059c87a7..594a087623519a4dbfa91803785a1e39aac37aa7 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """
 Simulation-specific flags.
@@ -14,7 +14,7 @@ application specific ones in e.g. atlas_flags.py.
 __author__  = 'A. Dell`Acqua, M. Gallas, Z. Marshall, A. Buckley'
 
 
-import re, os, sys
+import os
 from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer, jobproperties
 
 # TODO: Needed? If so, edit this comment to explain why :)
@@ -221,12 +221,12 @@ class PhysicsList(JobProperty):
                 if n_value not in self.allowedValues:
                     self.allowedValues.append(n_value)
         if n_value == 'FTFP_BERT_G4Precompound':
-            _sflog.warning('Setting G4CASCADE_USE_PRECOMPOUND for use of ' +
+            _sflog.warning('Setting G4CASCADE_USE_PRECOMPOUND for use of '
                            'precompound model' )
             os.environ['G4CASCADE_USE_PRECOMPOUND'] = '1'
             n_value = 'FTFP_BERT'
         elif 'G4CASCADE_USE_PRECOMPOUND' in os.environ:
-            _sflog.warning('Setting G4CASCADE_USE_PRECOMPOUND back to 0 ' +
+            _sflog.warning('Setting G4CASCADE_USE_PRECOMPOUND back to 0 '
                            '(why was it set?)')
             os.environ['G4CASCADE_USE_PRECOMPOUND'] = '0'
         JobProperty.__setattr__(self, name, n_value)
@@ -371,13 +371,12 @@ class RandomSeedList(JobProperty):
         """Add seeds to internal seedlist. Seeds will be incremented by offset values."""
         newseed = name + " OFFSET " + str(jobproperties.SimFlags.RandomSeedOffset.get_Value()) + " " + str(seed1) + " " + str(seed2) #option 1b
 
-        _sflog.info("Adding Simulation random number seed '" + newseed + "'")
+        _sflog.info("Adding Simulation random number seed %s", newseed)
 
         ## Ensure that each stream is only initialized once
         found = self.checkForExistingSeed(name)
         if found:
-            _sflog.error("Initialization values for random number stream " +
-                         name + " already exist!")
+            _sflog.error("Initialization values for random number stream %s already exist!", name)
         else:
             seedlist = self.get_Value()
             seedlist += [newseed]
@@ -387,10 +386,9 @@ class RandomSeedList(JobProperty):
         """print random seeds """
         from AthenaCommon.ConfigurableDb import getConfigurable
         rndmSvc = getConfigurable(jobproperties.SimFlags.RandomSvc.get_Value())()
-        _sflog.info("Random Number Seeds stored in simFlag: " +
-                    str(self.get_Value()))
-        _sflog.info("Random Number Seeds attached to Service '" +
-                    rndmSvc.name() + "': " + str(rndmSvc.Seeds))
+        _sflog.info("Random Number Seeds stored in simFlag: %s", self.get_Value())
+        _sflog.info("Random Number Seeds attached to Service '%s': %s",
+                    rndmSvc.name(), rndmSvc.Seeds)
 
     def checkRndmSvc(self):
         """Check if the random number service has already been defined"""
@@ -399,23 +397,22 @@ class RandomSeedList(JobProperty):
             from AthenaCommon.ConfigurableDb import getConfigurable
             rndmSvc = getConfigurable(jobproperties.SimFlags.RandomSvc.get_Value())()
             if len(rndmSvc.Seeds)!=0:
-                _sflog.warn(rndmSvc.name() + ".Seeds is not empty!")
-                _sflog.warn("Random Number Seeds already attached to Service '" +
-                            rndmSvc.name() + "': " + str(rndmSvc.Seeds))
+                _sflog.warn("%s.Seeds is not empty!", rndmSvc.name())
+                _sflog.warn("Random Number Seeds already attached to Service '%s': ",
+                            rndmSvc.name(), rndmSvc.Seeds)
                 _sflog.warn("Please use simFlags.RandomSeedList.addSeed() instead!")
                 for seedstring in rndmSvc.Seeds:
                     if 'OFFSET' not in seedstring:
-                        _sflog.warn("Existing Seed: '" + seedstring +
-                                    "' incorrectly defined - missing OFFSET! " +
-                                    "Removing...")
+                        _sflog.warn("Existing Seed: '%s' "
+                                    "incorrectly defined - missing OFFSET! "
+                                    "Removing...", seedstring)
                     else:
                         # If seed is correctly formatted add seed properly after
                         # checking it hasn't already been defined in the stream list.
                         splitseedstring = seedstring.split()
                         if self.checkForExistingSeed(splitseedstring[0]):
-                            _sflog.error("Initialization values for random " +
-                                         "number stream " + splitseedstring[0] +
-                                         " already exist!")
+                            _sflog.error("Initialization values for random "
+                                         "number stream %s already exist!", splitseedstring[0])
                         else:
                             self.addSeed( splitseedstring[0], splitseedstring[3],
                                           splitseedstring[4] )
@@ -426,8 +423,8 @@ class RandomSeedList(JobProperty):
         """
         from AthenaCommon.ConfigurableDb import getConfigurable
         rndmSvc = getConfigurable(jobproperties.SimFlags.RandomSvc.get_Value())()
-        _sflog.info("Adding Simulation random number seed stored in jobProperties " +
-                    "to Random Number Service '" + rndmSvc.name() + "'")
+        _sflog.info("Adding Simulation random number seed stored in jobProperties "
+                    "to Random Number Service '%s'", rndmSvc.name())
         self.checkRndmSvc()
         rndmSvc.Seeds += self.get_Value()
         from GaudiKernel.Configurable import WARNING
@@ -623,7 +620,7 @@ class RunDict(JobProperty):
     statusOn = True
     allowedTypes = ['dict']
     StoredValue = { 197451 : 1 , 201445 : 1 }
-    def GetRunNumber( a_job ):
+    def GetRunNumber(self, a_job ):
         """
         Get a run number based on the runs in the dictionary.  Returns
         as though we process a linear sequence for the moment
@@ -638,8 +635,8 @@ class RunDict(JobProperty):
             for a in self.get_Value():
                 if baseJN<=self.get_Value()[a]: return a
                 else: baseJN-= self.get_Value()[a]
-        _sflog.warning('Something went wrong with job ' + str(a_job) +
-                       '. Returning run number -1.' )
+        _sflog.warning('Something went wrong with job %s.'
+                       'Returning run number -1.', a_job )
         return -1
 
 class DoLArBirk(JobProperty):
@@ -743,8 +740,8 @@ class OptionalUserActionList(JobProperty):
             try:
                 self.StoredValue[role] += [actionTool]
             except KeyError:
-                _sflog.warn('Attempt to assign action %s to role %s not allowed' %
-                            (actionTool, role))
+                _sflog.warn('Attempt to assign action %s to role %s not allowed',
+                            actionTool, role)
 
     def removeAction(self, actionTool, roles=['General']):
         # Remove the action from the list of actions - no error if role isn't in the list.
@@ -752,11 +749,11 @@ class OptionalUserActionList(JobProperty):
             try:
                 self.StoredValue[role].remove(actionTool)
             except KeyError:
-                _sflog.warn('Attempt to remove action %s from role %s not allowed' %
-                            (actionTool, role))
+                _sflog.warn('Attempt to remove action %s from role %s not allowed',
+                            actionTool, role)
             except ValueError:
-                _sflog.warn('Attempt to remove unknown action %s from role %s' %
-                            (actionTool, role))
+                _sflog.warn('Attempt to remove unknown action %s from role %s',
+                            actionTool, role)
 
 class G4Commands(JobProperty):
     """
@@ -858,9 +855,9 @@ class SimFlags(JobPropertyContainer):
         """
         Load extra config flags specific to ATLAS layouts.
         """
-        if not "atlas_flags" in self.extra_flags:
+        if "atlas_flags" not in self.extra_flags:
             self._log.info("SimFlags:: Loading ATLAS flags")
-            if not "ATLAS-" in self.SimLayout.get_Value():
+            if "ATLAS-" not in self.SimLayout.get_Value():
                 self._log.warning("Loading ATLAS flags, but SimLayout tag is not an ATLAS geometry")
             self.extra_flags.append("atlas_flags")
             self.import_JobProperties('G4AtlasApps.atlas_flags')
@@ -870,7 +867,7 @@ class SimFlags(JobPropertyContainer):
         """
         Load extra config flags specific to cosmics simulation.
         """
-        if not "cosmics_flags" in self.extra_flags:
+        if "cosmics_flags" not in self.extra_flags:
             self._log.info("SimFlags:: Loading cosmics flags")
             self.extra_flags.append("cosmics_flags")
             self.import_JobProperties('CosmicGenerator.cosmics_flags')
@@ -880,9 +877,9 @@ class SimFlags(JobPropertyContainer):
         """
         Load extra config flags specific to CTB layouts.
         """
-        if not "ctb_flags" in self.extra_flags:
+        if "ctb_flags" not in self.extra_flags:
             self._log.info("SimFlags:: Loading CTB flags")
-            if not "ctbh8" in self.SimLayout.get_Value():
+            if "ctbh8" not in self.SimLayout.get_Value():
                 self._log.warning("Loading CTB flags, but SimLayout tag is not a CTB geometry")
             self.extra_flags.append("ctb_flags")
             self.import_JobProperties('G4AtlasApps.ctb_flags')
@@ -892,9 +889,9 @@ class SimFlags(JobPropertyContainer):
         """
         Load extra config flags specific to TB LAr H6 layouts.
         """
-        if not "tbLArH6_flags" in self.extra_flags:
+        if "tbLArH6_flags" not in self.extra_flags:
             self._log.info("SimFlags:: Loading TB LAr H6 flags")
-            if not "tb_LArH6" in self.SimLayout.get_Value():
+            if "tb_LArH6" not in self.SimLayout.get_Value():
                 self._log.warning("Loading TB LAr H6 flags, but SimLayout tag is not a TB LAr H6 geometry")
             self.extra_flags.append("tbLArH6_flags")
             self.import_JobProperties('G4AtlasApps.tbLArH6_flags')
@@ -904,9 +901,9 @@ class SimFlags(JobPropertyContainer):
         """
         Load extra config flags specific to TB Tile layouts.
         """
-        if not "tbtile_flags" in self.extra_flags:
+        if "tbtile_flags" not in self.extra_flags:
             self._log.info("SimFlags:: Loading TB Tile flags")
-            if not "tb_Tile2000_2003" in self.SimLayout.get_Value():
+            if "tb_Tile2000_2003" not in self.SimLayout.get_Value():
                 self._log.warning("Loading TB Tile flags, but SimLayout tag is not a TB Tile geometry")
             self.extra_flags.append("tbtile_flags")
             self.import_JobProperties('G4AtlasApps.tbtile_flags')
@@ -920,7 +917,7 @@ for jpname in dir():
     import inspect
     if inspect.isclass(jp):
         if issubclass(jp, JobProperty) and jp is not JobProperty:
-            _sflog.debug("Adding SimFlag '%s' to SimFlags container" % jpname)
+            _sflog.debug("Adding SimFlag '%s' to SimFlags container", jpname)
             jobproperties.SimFlags.add_JobProperty(jp)
 
 
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimSkeleton.py b/Simulation/G4Atlas/G4AtlasApps/python/SimSkeleton.py
index 93fc74e1b0dce7a2eee4ac4ba4233839080c4430..b9a978b7a5cbd81aea476bb811e0bf4ae8c83f25 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/SimSkeleton.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/SimSkeleton.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from G4AtlasApps import AtlasG4Eng
 
@@ -218,9 +218,7 @@ class SimSkeleton(object):
             AtlasG4Eng.G4Eng.log.verbose('SimSkeleton._do_persistency :: starting')
 
             ## The following used to be in G4AtlasApps/HitAthenaPoolWriteOptions
-            from AthenaCommon.DetFlags import DetFlags
-            from AthenaCommon.Configurable import Configurable
-            from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream
+            import AthenaPoolCnvSvc.WriteAthenaPool  # noqa: F401
 
             ## Default setting for one output stream
             from AthenaCommon.AppMgr import ServiceMgr as svcMgr
@@ -229,7 +227,7 @@ class SimSkeleton(object):
             svcMgr.AthenaPoolCnvSvc.PoolAttributes += [ "DatabaseName = '" + athenaCommonFlags.PoolHitsOutput() + "'; ContainerName = 'TTree=CollectionTree'; TREE_AUTO_FLUSH = '1'" ]
 
             ## Write geometry tag info
-            import EventInfoMgt.EventInfoMgtInit
+            import EventInfoMgt.EventInfoMgtInit  # noqa: F401
 
             ## Instantiate StreamHITS
             if athenaCommonFlags.PoolHitsOutput.statusOn:
@@ -260,12 +258,13 @@ class SimSkeleton(object):
         from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
         ## ReadTR is only present in simFlags for ATLAS geometries with cosmics switched on
         if (not simFlags.ISFRun) and hasattr(simFlags, "ReadTR") and simFlags.ReadTR.statusOn:
+            from AthenaCommon.Include import include
             include("CosmicGenerator/SetCosmicGenerator.py")
 
         if athenaCommonFlags.PoolEvgenInput.statusOn:
             ## Tell the event selector about the evgen input files and event skipping
             if not hasattr(svcMgr, 'EventSelector'):
-                import AthenaPoolCnvSvc.ReadAthenaPool
+                import AthenaPoolCnvSvc.ReadAthenaPool  # noqa: F401
             svcMgr.EventSelector.InputCollections = athenaCommonFlags.PoolEvgenInput()
             if athenaCommonFlags.SkipEvents.statusOn:
                 svcMgr.EventSelector.SkipEvents = athenaCommonFlags.SkipEvents()
@@ -274,7 +273,7 @@ class SimSkeleton(object):
         else:
             ## No input file so assume that we are running a Generator in the same job
             if not hasattr(svcMgr, 'EventSelector'):
-                import AthenaCommon.AtlasUnixGeneratorJob
+                import AthenaCommon.AtlasUnixGeneratorJob  # noqa: F401
             # TODO: Check that there is at least one algorithm already in the AlgSequence?
             ## Warn if attempting to skip events in a generator job
             if athenaCommonFlags.SkipEvents.statusOn and athenaCommonFlags.SkipEvents()!=0:
@@ -314,16 +313,16 @@ class SimSkeleton(object):
         ## Execute the known methods from the known_methods in pre_init
         for k in known_methods:
             try:
-                AtlasG4Eng.G4Eng.log.debug('SimSkeleton._do_PreInit :: evaluating method ' + k)
+                AtlasG4Eng.G4Eng.log.debug('SimSkeleton._do_PreInit :: evaluating method %s', k)
                 getattr(cls, k).__call__()
             except Exception as err:
                 print ("Error: %s" % str(err))
                 import traceback,sys
                 traceback.print_exc(file=sys.stdout)
-                raise RuntimeError('SimSkeleton._do_PreInit :: found problems with the method  %s' % k)
+                raise RuntimeError('SimSkeleton._do_PreInit :: found problems with the method  %s', k)
 
          ## Run pre-init callbacks
-        AtlasG4Eng.G4Eng.log.debug("AtlasG4Eng.G4Eng:init stage " + "preInit")
+        AtlasG4Eng.G4Eng.log.debug("AtlasG4Eng.G4Eng:init stage preInit")
         if simFlags.InitFunctions.statusOn and "preInit" in simFlags.InitFunctions.get_Value():
             for callback_fn in simFlags.InitFunctions.get_Value()["preInit"]:
                     callback_fn.__call__()
@@ -343,7 +342,7 @@ class SimSkeleton(object):
         ## Execute the known methods from the known_methods list
         for k in known_methods:
             try:
-                AtlasG4Eng.G4Eng.log.debug('SimSkeleton :: evaluating method ' +k)
+                AtlasG4Eng.G4Eng.log.debug('SimSkeleton :: evaluating method %s', k)
                 getattr(cls, k).__call__()
             except Exception as err:
                 print ("Error: %s" % str(err))
@@ -354,7 +353,7 @@ class SimSkeleton(object):
         for i in dir(cls):
             if i.find('do_') == 0 and i not in known_methods:
                try:
-                   AtlasG4Eng.G4Eng.log.debug('SimSkeleton :: evaluating method %s' % i)
+                   AtlasG4Eng.G4Eng.log.debug('SimSkeleton :: evaluating method %s',  i)
                    getattr(cls, i).__call__()
                except Exception as err:
                    print ("Error: %s" % str(err))
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilhisto.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilhisto.py
index c4707b9458ebe56fe5e880f9314cef3bc84077e7..22f757e66280182e643459208cceb0d1b94589d6 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilhisto.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilhisto.py
@@ -9,8 +9,6 @@ ROOT file .
 
 # TODO: Remove? Totally unused, I think.  (AB, 07/2011)
 
-from __future__ import print_function
-
 __author__ = 'M. Gallas'
 
 class HistoAtHistoSvc(object):
@@ -61,7 +59,7 @@ class HistoAtHistoSvc(object):
     def retrieve_historoot(self,root_file_name,root_histo_name):
         """ Retrieves a TH1F ROOT histogram.
         """
-        from ROOT import TFile, TH1F
+        from ROOT import TFile
         self.RootHistoName=root_histo_name
         self.RootFileName=(root_file_name)
         self.RootFile=TFile(self.RootFileName)
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilities.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilities.py
index 6756f78439d8f232f3c1a0ca97a3653c9dcb2da1..2caad39623ab837b8d061c5160f029da4e9e3c2a 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilities.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_utilities.py
@@ -7,8 +7,6 @@ Provide different utilities like:
   _frozen = a base class / metaclass for making objects immutable
 """
 
-from __future__ import print_function
-
 __author__  = 'A. Dell`Acqua, M. Gallas, A. Di Simone'
 
 ## ATLAS generic scintillator SD
@@ -29,7 +27,7 @@ class ScintillatorSD(object):
         import AtlasG4Eng
         AtlasG4Eng.G4Eng.load_Lib('G4AncillarySD')
         AtlasG4Eng.G4Eng.load_Dict('G4AncillarySDDict')
-        SD_HChandler = AtlasG4Eng.G4Eng.gbl.ScintillatorSD_PyHandler()
+        #SD_HChandler = AtlasG4Eng.G4Eng.gbl.ScintillatorSD_PyHandler()
         #import PyG4Atlas
         ## SD = PyG4Atlas.SenDetector('G4AncillarySD', 'ScintillatorSD', 'ScintillatorSD') #FIXME SD to be migrated ATLASSIM-1752
         ## # Make a ScintillatorSD hit collection and each associated volume has a
@@ -67,7 +65,7 @@ class MemorySnooper(PyAthena.Alg):
         """
         Checks the memory at any time and print it to a file.
         """
-        import os, string, time
+        import os, time
         now = time.time()
         elapsed_time = now - self.now
         self.now = now
@@ -84,7 +82,7 @@ class MemorySnooper(PyAthena.Alg):
         only if is different from the previous value obtained.
         This method is for the use in the execute method (event by event).
         """
-        import os, string, time
+        import os, time
         now = time.time()
         elapsed_time = now - self.now
         self.now = now
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py b/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py
index 8453cec076774ecb8253e9ac3b892f2397174d20..57dd4e58f550d8a33ff50055b60bf313df89e409 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py
@@ -1,7 +1,5 @@
 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
-from __future__ import print_function
-
 """
 - This module contains the common volumes, sub-detector envelopes,
   magnets, beam pipes, volumes for MCTruth and other common stuff
@@ -21,9 +19,6 @@ __author__ = 'M. Gallas'
 import math
 import PyG4Atlas, AtlasG4Eng
 from PyG4Atlas import DetFacilityT
-from atlas_materials import material_concrete
-from atlas_materials import material_mylar
-from atlas_materials import material_scintillator
 
 #=======================================================================
 # - CTB top volumes  ---------------------------------------------------
@@ -169,15 +164,15 @@ class LArFarUpstreamMaterial(object):
             self.material.df.MoveTo(self.material.position)
             AtlasG4Eng.G4Eng.add_DetFacility(self.material,\
                      AtlasG4Eng.G4Eng.Dict_DetFacility.get('CTB'))
-            AtlasG4Eng.G4Eng.log.info(' LArFarUpstreamMaterial is placed inside CTB '+\
-                   'at -20000 mm. ')
+            AtlasG4Eng.G4Eng.log.info(' LArFarUpstreamMaterial is placed inside CTB '
+                                      'at -20000 mm. ')
         elif(option==1):
             self.material.position=AtlasG4Eng.G4Eng.gbl.Hep3Vector(-1020.,0.,0.)
             self.material.df.MoveTo(self.material.position)
             AtlasG4Eng.G4Eng.add_DetFacility(self.material,\
                      AtlasG4Eng.G4Eng.Dict_DetFacility.get('IDET'))
-            AtlasG4Eng.G4Eng.log.info(' LArFarUpstreamMaterial is placed inside IDET '+\
-                   'at -1020 mm in order to use BeamConditions ')
+            AtlasG4Eng.G4Eng.log.info(' LArFarUpstreamMaterial is placed inside IDET '
+                                      'at -1020 mm in order to use BeamConditions ')
 
 # - Magnets  -----------------------------------------------------------
 __doc__+="""\n\n         -- MAGNETS -- \n"""
@@ -351,7 +346,7 @@ class ctb_beampipes_and_magnetsupstream:
             AtlasG4Eng.G4Eng.add_DetFacility(beampipe2,mbpl12)
             AtlasG4Eng.G4Eng.add_DetFacility(mylarequiv,ctb)
         if(mode==2):
-            equivupstreammaterial=EquivUpstreamMaterial()
+            equivupstreammaterial=EquivUpstreamMaterial()  # noqa: F841 (needed?)
 
 # - Muon-DUMP  ---------------------------------------------------------
 __doc__+="""\n\n         -- MUON DUMP -- \n"""
@@ -669,7 +664,7 @@ class CombinedScintillator:
        #self.ctb_combinedscintillator_position=AtlasG4Eng.G4Eng.gbl.CLHEP.Hep3Vector(-2.0,0.0,2200.)
         if (eta==0):
           self.ctb_combinedscintillator_position=AtlasG4Eng.G4Eng.gbl.CLHEP.Hep3Vector(-2.0,0.0,0.)
-        elif(eta>0,eta<=0.95):
+        elif(eta>0 and eta<=0.95):
           self.ctb_combinedscintillator_position=AtlasG4Eng.G4Eng.gbl.CLHEP.Hep3Vector(-2.0,0.0,\
                      2274.0/math.tan(2*math.atan(math.exp(-eta))) )
         elif(eta>0.95):
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/ctb_field.py b/Simulation/G4Atlas/G4AtlasApps/python/ctb_field.py
index ca7965b9a1920aa6e94c23e88fa587c2e6b761b5..8e8ee9ebb669e70466cdb892ad098655fb08c059 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/ctb_field.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/ctb_field.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """
 This module adds the magnetic fields to the CTB simulation
@@ -72,7 +72,7 @@ class CTBFieldMap(object):
         for i in dataPathList:
             if 'CTB' in i and 'magfield' in i:
                 self.mag_data_path = i
-                AtlasG4Eng.G4Eng.log.debug('ctb_field::CTBFieldMap found the datapath for field maps at %s' % self.mag_data_path)
+                AtlasG4Eng.G4Eng.log.debug('ctb_field::CTBFieldMap found the datapath for field maps at %s', self.mag_data_path)
         ## Restrict the field to the IDET volume
         if mode == 0:
             mapfield_CTB = PyG4Atlas.MagneticField('G4Field', 'G4AtlasFieldSvc', typefield='MapField')
@@ -94,7 +94,7 @@ class CTBFieldMap(object):
             try:
                 os.symlink(os.path.join(self.mag_data_path,fieldmap_name),
                            os.path.join(os.getcwd(),'magempty'))
-            except:
+            except Exception:
                 AtlasG4Eng.G4Eng.log.debug('ctb_field::CTBFieldMap DATAPATH not found --> try local link')
                 os.symlink(os.path.join(os.getcwd(),fieldmap_name),
                            os.path.join(os.getcwd(),'magempty'))
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_calo.py b/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_calo.py
index fbeaab689e79e4b76e8de467ccd9d79b35418e0a..66fa4228f1f9373745e0e529cb9ea61f06bd6de8 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_calo.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_calo.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """
  LAr H6 Calo detector description.
@@ -8,10 +8,7 @@
 __author__ = 'Joe Boudreau, Mohsen Kakhzad, Margret Fincke-Keeler, \
               J.P. Archambault, M. Gallas, A. Soukharev'
 
-import math
 from G4AtlasApps import PyG4Atlas, AtlasG4Eng
-from G4AtlasApps.PyG4Atlas import  DetFacility, PhysicsReg
-
 
 # -- World volume --
 class LArWorld(object):
@@ -47,7 +44,6 @@ class Det_Layouts:
 
         AtlasG4Eng.G4Eng.load_Dict('LArG4RunControlDict')
         import ROOT
-        import __main__
         from G4AtlasApps.SimFlags import simFlags
         if (simFlags.SimLayout.get_Value()=="tb_LArH6_2002"):
             pd=AtlasG4Eng.G4Eng.gbl.LArGeoTBH1GeoOptions()
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_flags.py b/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_flags.py
index 565d026931c5629050d73a1303df23e43a7878d2..7636f7f552344da60efc53f5bf42db5ca44fcbbd 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_flags.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/tbLArH6_flags.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 """ Simulation specific flags.
 
@@ -20,7 +20,7 @@ from AthenaCommon.JobProperties import JobProperty
 
 # We re-use already defined flags that maybe we will customize here
 from G4AtlasApps.SimFlags import jobproperties
-from ctb_flags import *
+from ctb_flags import *  # noqa: F401 F403
 # 25/03/2008  A.M.  added  by analogy with atlas_flags.py
 
 jobproperties.SimFlags.CalibrationRun.set_Off()
diff --git a/Simulation/G4Atlas/G4AtlasApps/python/tbtile_flags.py b/Simulation/G4Atlas/G4AtlasApps/python/tbtile_flags.py
index b1819bc8e5a524b5d1a9064ea064978b97a90573..b64ea8e49f2ecfe2f1f7bc44569820f334f35f65 100644
--- a/Simulation/G4Atlas/G4AtlasApps/python/tbtile_flags.py
+++ b/Simulation/G4Atlas/G4AtlasApps/python/tbtile_flags.py
@@ -58,7 +58,6 @@ class Eta(JobProperty):
         #print (name, n_value)
         if name == "StoredValue":
             if type(n_value) == int or type (n_value) == float:
-                import math
                 if abs(n_value) > 1.1:
                     raise ValueError ('THE ETA VALUE MUST BE IN [-1.1,1.1]!!! The selected value %s is not in the range.' %n_value)
         JobProperty.__setattr__(self, name, n_value)
@@ -83,7 +82,6 @@ class Theta(JobProperty):
         #print (name, n_value)
         if name == "StoredValue":
             if type(n_value) == int or type (n_value) == float:
-                import math
                 if abs(n_value) > 60. and not (abs(abs(n_value)-90.0) < 0.01) :
                     raise ValueError ('THETA MUST BE IN [-60,60] or +/-90 !!! The selected value %s is not in the range.' %n_value)
         JobProperty.__setattr__(self, name, n_value)