Skip to content

Commit b1ff0b9

Browse files
committed
test: update to pylint 3.0.0 and diraccfg 1.0.0
1 parent 0141194 commit b1ff0b9

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def cfgPath(*args):
1818
return os.path.normpath(os.path.join(*(str(k) for k in args)))
1919

2020

21-
def cfgInstallPath(*args):
21+
def cfgInstallPath(*args) -> str:
2222
"""
2323
Path to Installation/Configuration Options
2424
"""

src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/DirectoryMetadata/DirectoryMetadata.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,8 @@ def getDirectoryMetaParameters(self, dpath, credDict, inherited=True):
350350
return S_OK({})
351351
metaDict = {}
352352
for _dID, key, value in result["Value"]:
353-
if key in metaDict:
354-
if isinstance(metaDict[key], list):
355-
metaDict[key].append(value)
356-
else:
357-
metaDict[key] = [metaDict[key]].append(value)
353+
if isinstance(metaDict.get(key), list):
354+
metaDict[key].append(value)
358355
else:
359356
metaDict[key] = value
360357

src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileMetadata/FileMetadata.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,8 @@ def __getFileMetaParameters(self, fileID, credDict):
358358
return S_OK({})
359359
metaDict = {}
360360
for fileID, key, value in result["Value"]:
361-
if key in metaDict:
362-
if isinstance(metaDict[key], list):
363-
metaDict[key].append(value)
364-
else:
365-
metaDict[key] = [metaDict[key]].append(value)
361+
if isinstance(metaDict.get(key), list):
362+
metaDict[key].append(value)
366363
else:
367364
metaDict[key] = value
368365

src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import subprocess
6666
from diraccfg import CFG
6767
from prompt_toolkit import prompt
68+
from typing import cast
6869

6970
import DIRAC
7071
from DIRAC import rootPath
@@ -170,7 +171,7 @@ def __init__(self):
170171
gLogger.debug("DIRAC Root Path =", rootPath)
171172

172173
self.mysqlMode = ""
173-
self.localCfg = None
174+
self.localCfg: CFG = None
174175
self.cfgFile = ""
175176
self.setup = ""
176177
self.instance = ""
@@ -1364,10 +1365,20 @@ def setupSite(self, scriptCfg, cfg=None):
13641365

13651366
# Now get the necessary info from self.localCfg
13661367
setupSystems = self.localCfg.getOption(cfgInstallPath("Systems"), ["Configuration", "Framework"])
1368+
13671369
setupDatabases = self.localCfg.getOption(cfgInstallPath("Databases"), [])
1368-
setupServices = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Services"), [])]
1369-
setupAgents = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Agents"), [])]
1370-
setupExecutors = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Executors"), [])]
1370+
setupServices = [
1371+
k.split("/")
1372+
for k in self.localCfg.getOption(cfgInstallPath("Services"), []) # pylint: disable=not-an-iterable
1373+
]
1374+
setupAgents = [
1375+
k.split("/")
1376+
for k in self.localCfg.getOption(cfgInstallPath("Agents"), []) # pylint: disable=not-an-iterable
1377+
]
1378+
setupExecutors = [
1379+
k.split("/")
1380+
for k in self.localCfg.getOption(cfgInstallPath("Executors"), []) # pylint: disable=not-an-iterable
1381+
]
13711382
setupWeb = self.localCfg.getOption(cfgInstallPath("WebPortal"), False)
13721383
setupConfigurationMaster = self.localCfg.getOption(cfgInstallPath("ConfigurationMaster"), False)
13731384
setupPrivateConfiguration = self.localCfg.getOption(cfgInstallPath("PrivateConfiguration"), False)
@@ -1382,7 +1393,7 @@ def setupSite(self, scriptCfg, cfg=None):
13821393
DIRAC.exit(-1)
13831394
return S_ERROR(error)
13841395
serviceSysInstance = serviceTuple[0]
1385-
if serviceSysInstance not in setupSystems:
1396+
if serviceSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test
13861397
setupSystems.append(serviceSysInstance)
13871398

13881399
for agentTuple in setupAgents:
@@ -1393,7 +1404,7 @@ def setupSite(self, scriptCfg, cfg=None):
13931404
DIRAC.exit(-1)
13941405
return S_ERROR(error)
13951406
agentSysInstance = agentTuple[0]
1396-
if agentSysInstance not in setupSystems:
1407+
if agentSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test
13971408
setupSystems.append(agentSysInstance)
13981409

13991410
for executorTuple in setupExecutors:
@@ -1404,7 +1415,7 @@ def setupSite(self, scriptCfg, cfg=None):
14041415
DIRAC.exit(-1)
14051416
return S_ERROR(error)
14061417
executorSysInstance = executorTuple[0]
1407-
if executorSysInstance not in setupSystems:
1418+
if executorSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test
14081419
setupSystems.append(executorSysInstance)
14091420

14101421
# And to find out the available extensions
@@ -1521,7 +1532,7 @@ def setupSite(self, scriptCfg, cfg=None):
15211532
# info to be propagated, this may cause the later self.setup to fail
15221533
if setupAddConfiguration:
15231534
gLogger.notice("Registering System instances")
1524-
for system in setupSystems:
1535+
for system in setupSystems: # pylint: disable=not-an-iterable
15251536
self.addSystemInstance(system, self.instance, self.setup, True)
15261537
for system, service in setupServices:
15271538
if not self.addDefaultOptionsToCS(None, "service", system, service, extensions, overwrite=True)["OK"]:
@@ -1570,7 +1581,7 @@ def setupSite(self, scriptCfg, cfg=None):
15701581
return result
15711582
dbDict = result["Value"]
15721583

1573-
for dbName in setupDatabases:
1584+
for dbName in setupDatabases: # pylint: disable=not-an-iterable
15741585
gLogger.verbose("Setting up database", dbName)
15751586
if dbName not in installedDatabases:
15761587
result = self.installDatabase(dbName)

src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_dtcache.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ def parseSwitches():
4343
args = Script.getPositionalArgs()
4444
if not args:
4545
error("Missing mandatory 'query' argument")
46+
DIRACExit(1)
4647
elif not args[0].lower() in ("select", "add", "delete"):
4748
error("Missing mandatory argument")
48-
else:
49-
query = args[0].lower()
49+
DIRACExit(1)
50+
51+
query = args[0].lower()
5052

5153
switches = dict(Script.getUnprocessedSwitches())
5254

0 commit comments

Comments
 (0)