Skip to content
Snippets Groups Projects
Commit bffb0143 authored by Johannes Elmsheuser's avatar Johannes Elmsheuser
Browse files

Merge branch 'flake_attr' into 'main'

Fix flake8-bugbear warnings

See merge request atlas/athena!71170
parents 2988b674 4b54b915
No related branches found
No related tags found
30 merge requests!78241Draft: FPGATrackSim: GenScan code refactor,!78236Draft: Switching Streams https://its.cern.ch/jira/browse/ATR-27417,!78056AFP monitoring: new synchronization and cleaning,!78041AFP monitoring: new synchronization and cleaning,!77990Updating TRT chip masks for L1TRT trigger simulation - ATR-28372,!77733Draft: add new HLT NN JVT, augmented with additional tracking information,!77731Draft: Updates to ZDC reconstruction,!77728Draft: updates to ZDC reconstruction,!77522Draft: sTGC Pad Trigger Emulator,!76725ZdcNtuple: Fix cppcheck warning.,!76611L1CaloFEXByteStream: Fix out-of-bounds array accesses.,!76475Punchthrough AF3 implementation in FastG4,!76474Punchthrough AF3 implementation in FastG4,!76343Draft: MooTrackBuilder: Recalibrate NSW hits in refine method,!75729New implementation of ZDC nonlinear FADC correction.,!75703Draft: Update to HI han config for HLT jets,!75184Draft: Update file heavyions_run.config,!74430Draft: Fixing upper bound for Delayed Jet Triggers,!73963Changing the path of the histograms to "Expert" area,!73875updating ID ART reference plots,!73874AtlasCLHEP_RandomGenerators: Fix cppcheck warnings.,!73449Add muon detectors to DarkJetPEBTLA partial event building,!73343Draft: [TrigEgamma] Add photon ringer chains on bootstrap mechanism,!72336Fixed TRT calibration crash,!72176Draft: Improving L1TopoOnline chain that now gets no-empty plots. Activating it by default,!72012Draft: Separate JiveXMLConfig.py into Config files,!71876Fix MET trigger name in MissingETMonitoring,!71820Draft: Adding new TLA End-Of-Fill (EOF) chains and removing obsolete DIPZ chains,!71279Draft: ATR-29330: Move L1_4J15 and the HLT chains seeded by it in the MC Menu,!71170Fix flake8-bugbear warnings
Showing
with 27 additions and 53 deletions
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
#
# File: CaloClusterCorrection/python/common.py
......@@ -879,9 +879,9 @@ def _config_from_jo (corr, jo, key, sampling, valid_keys, order):
parms = parms[sampling]
if order != 0 and hasattr (corr, 'order'):
setattr (corr, 'order', order)
corr.order = order
if hasattr (corr, 'isDummy'):
setattr (corr, 'isDummy', 0)
corr.isDummy = 0
log = logging.getLogger ('CaloClusterCorrection')
......
#!/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
import ROOT
from PyCool import cool
import os
#from CaloCondBlobAlgs import CaloCondTools, CaloCondLogger
def CaloCondBlobWriter(spec,valuePairs,defaultValue):
......@@ -31,8 +30,7 @@ def CaloCondBlobWriter(spec,valuePairs,defaultValue):
print ("Build CaloCondBlob object")
data = cool.Record( spec )
blob = data['CaloCondBlob16M']
#flt = g.CaloCondBlobFlt.getInstance(blob)
fltClass=getattr(ROOT,'CaloCondBlobFlt')
fltClass=ROOT.CaloCondBlobFlt
flt=fltClass.getInstance(blob)
flt.init(defVec,nChannels,1)
......
......@@ -260,8 +260,7 @@ def regSelToolsCfg(flags, detNames):
elif det == 'STGC':
flagName = 'sTGC'
detFlag = f'Enable{flagName}'
detFlagCont = getattr(flags, 'Detector')
detEnabled = getattr(detFlagCont, detFlag)
detEnabled = getattr(flags.Detector, detFlag)
if not detEnabled:
_log.debug('regSelToolsCfg: skip adding detector "%s" because the flag Detector.%s is False', det, detFlag)
continue
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
#==============================================================
# Job options file for the AFP_GlobReco package
......@@ -18,12 +18,7 @@ def AFP_GlobReco_Cfg(flags, kwargs={}):
# collect all output names and make a list with unique names for write handle keys; if this goes wrong AFP_GlobRecoTool::initialize() will complain
outputProtonList=[]
for protonTool in protonsToolsList:
try:
# in case the "protonsContainerName" is set
contName=getattr(protonTool, "protonsContainerName")
except AttributeError:
# in case the "protonsContainerName" is not set
contName=protonTool.getDefaultProperty("protonsContainerName")
contName=getattr(protonTool, "protonsContainerName", protonTool.getDefaultProperty("protonsContainerName"))
if contName not in outputProtonList:
outputProtonList.append(contName)
......
......@@ -41,7 +41,7 @@ def AFP_LocReco_SiD_Cfg(flags, kwargs={}):
for kalmanTool in kalmanToolsList:
try:
# in case the "tracksContainerName" is set
contName=getattr(kalmanTool, "tracksContainerName")
contName=kalmanTool.tracksContainerName
except AttributeError:
# in case the "tracksContainerName" is not set
contName=kalmanTool.getDefaultProperty("tracksContainerName")
......@@ -86,12 +86,7 @@ def AFP_LocReco_TD_Cfg(flags, kwargs={}):
# collect all output names and make a list with unique names for write handle keys; if this goes wrong AFP_TDLocRecoTool::initialize() will complain
outputBasicList=[]
for basicTool in basicToolsList:
try:
# in case the "tracksContainerName" is set
contName=getattr(basicTool, "tracksContainerName")
except AttributeError:
# in case the "tracksContainerName" is not set
contName=basicTool.getDefaultProperty("tracksContainerName")
contName=getattr(basicTool, "tracksContainerName", basicTool.getDefaultProperty("tracksContainerName"))
if contName not in outputBasicList:
outputBasicList.append(contName)
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
#==============================================================
# Job options file for the AFP_VertexReco package
......@@ -28,12 +28,7 @@ def AFP_VertexReco_Cfg(flags, kwargs={}):
# collect all output names and make a list with unique names for write handle keys; if this goes wrong AFP_VertexRecoTool::initialize() will complain
outputVertexList=[]
for vertexTool in verticesToolsList:
try:
# in case the "verticesContainerName" is set
contName=getattr(vertexTool, "verticesContainerName")
except AttributeError:
# in case the "verticesContainerName" is not set
contName=vertexTool.getDefaultProperty("verticesContainerName")
contName=getattr(vertexTool, "verticesContainerName", vertexTool.getDefaultProperty("verticesContainerName"))
if contName not in outputVertexList:
outputVertexList.append(contName)
......
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
## \file Herwig7Control.py
## \brief Main python interface for %Herwig7 for preparing the event generation
## \author Daniel Rauch (daniel.rauch@desy.de)
......@@ -111,7 +111,7 @@ def matchbox_run_gridpack(gen_config, integration_jobs, gridpack_name, cleanup_h
else:
## unpack the gridpack
DSIS_dir = getattr(gen_config.runArgs, 'jobConfig')[0]+"/"
DSIS_dir = gen_config.runArgs.jobConfig[0]+"/"
do_uncompress_gridpack(DSIS_dir+gridpack_name)
athMsgLog.info("Finished unpacking the gridpack")
......
......@@ -112,10 +112,10 @@ def getGainLayerNames(tool):
"""getGainLayerNames( tool ) -> return a list of names of the decorations added to the
egamma tool, given the GainDecorator tool"""
return [
getattr(tool, "decoration_pattern").format(info=info, layer=layer, gain=gain)
tool.decoration_pattern.format(info=info, layer=layer, gain=gain)
for info in ["E", "nCells"]
for layer in getattr(tool, "layers")
for gain in getattr(tool, "gain_names").values()
for layer in tool.layers
for gain in tool.gain_names.values()
]
......@@ -168,13 +168,13 @@ def getClusterEnergyPerLayerDecorations(acc, kernel):
for tool in ClusterEnergyPerLayerDecorators:
collections = filter(bool, (getattr(tool, x) for x in properties))
for part in collections:
for layer in getattr(tool, "layers"):
for layer in tool.layers:
decorations.extend(
[
"{part}.E{neta}x{nphi}_Lr{layer}".format(
part=part,
neta=getattr(tool, "neta"),
nphi=getattr(tool, "nphi"),
neta=tool.neta,
nphi=tool.nphi,
layer=layer,
)
]
......
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from copy import deepcopy
from math import ceil
......@@ -120,8 +120,7 @@ def loadPileUpProfile(flags, fragment_string):
from importlib import import_module
loaded_module = import_module(fragment_string)
function_def = getattr(loaded_module, 'setupProfile')
return function_def(flags)
return loaded_module.setupProfile(flags)
def generatePileUpProfile(flags,
......@@ -357,8 +356,7 @@ def setupPileUpProfile(flags):
from importlib import import_module
loaded_module = import_module(bunchStructure)
function_def = getattr(loaded_module, 'setupBunchStructure')
function_def(flags)
loaded_module.setupBunchStructure(flags)
# Setup pile-up profile
flags.Digitization.PU.NumberOfCollisions = flags.Digitization.PU.NumberOfLowPtMinBias + flags.Digitization.PU.NumberOfHighPtMinBias
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
__author__ = "clat@hep.ph.bham.ac.uk"
......@@ -287,7 +287,6 @@ class AllowedExpression:
class JobConfigMetaClass(type):
def __init__( self, name, bases, dict ):
## print "JobConfigMetaClass( self=%r, name=%r, bases=%r, dict=%r )" % (self,name,bases,dict)
if '__slots__' not in dict:
raise TransformConfigError('Class %s does not have member __slots__. Please add __slots__ = ()'
' to the class definition' % (name,) )
......@@ -296,24 +295,19 @@ class JobConfigMetaClass(type):
#
# first add it to __slots__
slots = self.__slots__
## print "%s.__slots__ before: = %r" % (self.__name__,slots)
descrName = '__properties'
if descrName not in slots:
# add variable
slots += ( descrName, )
# synchronise dict
dict['__slots__'] = slots
## print "%s.__slots__ after: = %r" % (self.__name__,slots)
# then add the list itself
setattr(self,descrName,[])
descrList = getattr(self,descrName)
# set names of properties and add them to the list of properties
for n,attrib in dict.items():
# attrib = getattr(self,n)
if isinstance(attrib,Descriptor):
## print "Setting name of %s.%s" % (self.__name__,n)
setattr(attrib,'_Descriptor__name',n)
## print "Adding %s.%s to %s.%s" % (self.__name__,n,self.__name__,descrName)
setattr(attrib,'_Descriptor__name',n) # noqa: B010 (private property)
descrList.append(attrib)
type.__init__(self,name,bases,dict)
......@@ -365,7 +359,7 @@ class JobConfig(with_metaclass(JobConfigMetaClass,object)):
## print "%s.properties()" % self.__name__
descr = []
for cl in self.__class__.__bases__ + (self.__class__,):
descr += getattr(cl,'__properties')
descr += getattr(cl,'__properties') # noqa: B009 (private property)
return descr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment