Skip to content
Snippets Groups Projects
Commit ed305a71 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Gaudi[Profiling,Svc,Configuration,Policy]: flake8 fixes

See merge request !1437
parents 769abd2a a193ddfc
No related branches found
No related tags found
1 merge request!1437Gaudi[Profiling,Svc,Configuration,Policy]: flake8 fixes
Pipeline #5470897 passed
Showing with 33 additions and 48 deletions
#####################################################################################
# (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -17,7 +17,7 @@ del ConfigurablesDB # no need to use this class after this point
import re
from sys import version_info
from GaudiConfig2._configurables import (
from GaudiConfig2._configurables import ( # noqa: F401
Configurable,
Property,
all_options,
......
......@@ -154,7 +154,7 @@ class Configurable(ConfigMetaHelper):
self._properties = {}
if "parent" in kwargs:
parent = kwargs.pop("parent")
if isinstance(parent, basestring if sys.version_info[0] == 2 else str):
if isinstance(parent, str):
parent = self.instances[parent]
if not name:
raise TypeError("name is needed when a parent is specified")
......@@ -182,10 +182,7 @@ class Configurable(ConfigMetaHelper):
def name(self, value):
if value == self._name:
return # it's already the name of the instance, nothing to do
if (
not isinstance(value, basestring if sys.version_info[0] == 2 else str)
or not value
):
if not isinstance(value, str) or not value:
raise TypeError(
"expected string, got {} instead".format(type(value).__name__)
)
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -80,7 +80,7 @@ def test_diff_unnamed():
@raises(ValueError)
def test_merge():
def test_merge_conflict():
a = MyAlg("ThisAlg", AnIntProp=42)
b = MyAlg("ThisAlg", AnIntProp=50)
a.merge(b)
......
#####################################################################################
# (c) Copyright 2022 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 2022-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -9,13 +9,7 @@
# or submit itself to any jurisdiction. #
#####################################################################################
from GaudiConfig2 import Configurable, useGlobalInstances
from GaudiConfig2.semantics import (
ComponentSemantics,
DefaultSemantics,
StringSemantics,
getSemanticsFor,
)
from nose.tools import raises, with_setup
from nose.tools import with_setup
def setup_func():
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -10,7 +10,7 @@
#####################################################################################
import GaudiConfig2._configurables
from GaudiConfig2 import Configurable, useGlobalInstances
from GaudiConfig2.Configurables.TestConf import MyAlg, SimpleOptsAlgTool
from GaudiConfig2.Configurables.TestConf import MyAlg
from nose.tools import raises, with_setup
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -76,11 +76,11 @@ def test_bool():
def test_float_ok():
s = getSemanticsFor("double")
assert type(s.store(1)) is float
assert s.store(1e30) is 1e30
assert s.store(1e30) == 1e30
s = getSemanticsFor("float")
assert type(s.store(1)) is float
assert s.store(1e30) is 1e30
assert s.store(1e30) == 1e30
@raises(TypeError)
......
#####################################################################################
# (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -9,7 +9,6 @@
# or submit itself to any jurisdiction. #
#####################################################################################
import inspect
import json
import logging
import os
......@@ -152,7 +151,7 @@ class BaseTest(object):
if self.options:
if re.search(
r"from\s+Gaudi.Configuration\s+import\s+\*|"
"from\s+Configurables\s+import",
r"from\s+Configurables\s+import",
self.options,
):
suffix, lang = ".py", "python"
......@@ -395,7 +394,7 @@ class BaseTest(object):
msg = "standard output"
# I do not want 2 messages in causes if the function is called
# twice
if not msg in causes:
if msg not in causes:
causes.append(msg)
result[res_field + ".observed"] = result.Quote("\n".join(outlines))
except ValueError:
......@@ -682,7 +681,8 @@ class BaseTest(object):
# function to split an extension in constituents parts
import re
platformSplit = lambda p: set(re.split(r"[-+]", p))
def platformSplit(p):
return set(re.split(r"[-+]", p))
reference = os.path.normpath(
os.path.join(self.basedir, os.path.expandvars(reffile))
......@@ -718,10 +718,8 @@ class BaseTest(object):
# ======= GAUDI TOOLS =======
import calendar
import difflib
import shutil
import string
try:
from GaudiKernel import ROOT6WorkAroundEnabled
......@@ -772,7 +770,6 @@ def which(executable):
# -------------------------------------------------------------------------#
# ----------------------------- Result Classe -----------------------------#
# -------------------------------------------------------------------------#
import types
class Result:
......@@ -1392,7 +1389,7 @@ def parseHistosSummary(lines, pos):
pos += 1
else: # not interpreted
raise RuntimeError("Cannot understand line %d: '%s'" % (pos, l))
if not d in summ:
if d not in summ:
summ[d] = {}
summ[d][t] = cont
summ[d]["header"] = header
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -10,9 +10,9 @@
#####################################################################################
import logging
import os
import sys
from GaudiTesting.BaseTest import *
from GaudiTesting.BaseTest import * # noqa: F401 F403 (to bring validators into scope)
from GaudiTesting.BaseTest import BaseTest
class QMTTest(BaseTest):
......
#####################################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 2021, 2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -9,4 +9,4 @@
# or submit itself to any jurisdiction. #
#####################################################################################
# allow from GaudiTesting import SKIP_RETURN_CODE
from .BaseTest import SKIP_RETURN_CODE
from .BaseTest import SKIP_RETURN_CODE # noqa: F401
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -10,9 +10,6 @@
#####################################################################################
from __future__ import print_function
import os
import sys
import time
from xml.etree import ElementTree
......@@ -111,13 +108,13 @@ class XmlDictObject(dict):
def _ConvertDictToXmlRecurse(parent, dictitem):
assert type(dictitem) is not type([])
assert not isinstance(dictitem, list)
if isinstance(dictitem, dict):
for (tag, child) in dictitem.iteritems():
if str(tag) == "_text":
parent.text = str(child)
elif type(child) is type([]):
elif isinstance(child, list):
# iterate through the array and convert
for listchild in child:
elem = ElementTree.Element(tag)
......@@ -154,7 +151,7 @@ def _ConvertXmlToDictRecurse(node, dictclass):
newitem = _ConvertXmlToDictRecurse(child, dictclass)
if child.tag in nodedict:
# found duplicate tag, force a list
if type(nodedict[child.tag]) is type([]):
if isinstance(nodedict[child.tag], list):
# append to existing list
nodedict[child.tag].append(newitem)
else:
......@@ -186,7 +183,7 @@ def ConvertXmlToDict(root, dictclass=XmlDictObject):
"""
# If a string is passed in, try to open it as a file
if type(root) == type(""):
if isinstance(root, str):
root = ElementTree.parse(root).getroot()
elif not isinstance(root, ElementTree.Element):
raise TypeError("Expected ElementTree.Element or file path string")
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -10,6 +10,6 @@
#####################################################################################
# for ATLAS: ease transition to GaudiSvc split
from GaudiCommonSvc.GaudiCommonSvcConf import *
from GaudiCoreSvc.GaudiCoreSvcConf import *
from GaudiMonitor.GaudiMonitorConf import *
from GaudiCommonSvc.GaudiCommonSvcConf import * # noqa: F401 F403
from GaudiCoreSvc.GaudiCoreSvcConf import * # noqa: F401 F403
from GaudiMonitor.GaudiMonitorConf import * # noqa: F401 F403
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