Skip to content

Commit 65cfb3e

Browse files
committed
Fix E711 None comparison ruff lint
1 parent fc600fe commit 65cfb3e

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

channelfinder/cfMonitorTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main():
5050
help="the --final-file",
5151
)
5252
opts, args = parser.parse_args()
53-
if args == None or len(args) == 0:
53+
if not args:
5454
parser.error("Please specify a directory")
5555
if not opts.initialFile:
5656
parser.error("Please specify a initial test files")

channelfinder/cfPropertyManager/CFPropertyManager.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def readConfiguration(path):
6262
print("IGNORE " + properties[1])
6363
exclusion_expression = re.compile(properties[1])
6464
else:
65-
if client.findProperty(properties[0]) != None:
65+
if client.findProperty(properties[0]) is not None:
6666
try:
6767
expression = re.compile(properties[1])
6868
expression_list.append([expression, properties[0]])
@@ -88,13 +88,13 @@ def applyExpression():
8888
exclusion_expression = "[^_]+"
8989
for channel_name in dbllines:
9090
prop_list = []
91-
if exclusion_expression.search(channel_name) != None:
91+
if exclusion_expression.search(channel_name) is not None:
9292
if verbose:
9393
print("EXCLUDE: " + channel_name)
9494
else:
9595
for expression in expression_list:
9696
result = expression[0].search(channel_name)
97-
if result != None:
97+
if result is not None:
9898
value = clean(result.group())
9999
if verbose:
100100
print("FOUND: " + value + " in " + channel_name)
@@ -156,7 +156,7 @@ def __getDefaultConfig(arg, value):
156156
"""
157157
Clean reception of command line configurations for default assignment.
158158
"""
159-
if value == None:
159+
if value is None:
160160
try:
161161
return basecfg.get("DEFAULT", arg)
162162
except:
@@ -211,7 +211,7 @@ def main():
211211
help="prompt user for password",
212212
)
213213
opts, args = parser.parse_args()
214-
if len(args) == 0 or args == None:
214+
if not args:
215215
parser.error("Please specify a file")
216216
mainRun(opts, args)
217217

@@ -227,11 +227,11 @@ def mainRun(opts, args):
227227
password = __getDefaultConfig("password", opts.password)
228228
SERVICE_URL = __getDefaultConfig("serviceURL", opts.serviceURL)
229229
verbose = __getDefaultConfig("verbose", opts.verbose)
230-
if username == None:
230+
if username is None:
231231
username = "cf-update" # CURRENT DEFAULT
232-
if password == None:
232+
if password is None:
233233
password = "1234" # CURRENT DEFAULT
234-
if SERVICE_URL == None:
234+
if SERVICE_URL is None:
235235
SERVICE_URL = "https://localhost:8181/ChannelFinder" # CURRENT DEFAULT
236236
startClient()
237237
run(args[0], args[1])

channelfinder/cfUpdate/CFUpdateIOC.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def updateChannelFinder(
7676
username = channelfinder username
7777
password = channelfinder password
7878
"""
79-
if hostName == None or iocName == None:
79+
if hostName is None or iocName is None:
8080
raise RuntimeError("missing hostName or iocName")
8181
channels = []
8282
try:
@@ -89,9 +89,9 @@ def updateChannelFinder(
8989
previousChannelsList = client.findByArgs(
9090
[("hostName", hostName), ("iocName", iocName)]
9191
)
92-
if previousChannelsList != None:
92+
if previousChannelsList is not None:
9393
for ch in previousChannelsList:
94-
if pvNames != None and ch["name"] in pvNames:
94+
if pvNames is not None and ch["name"] in pvNames:
9595
""""""
9696
channels.append(
9797
updateChannel(
@@ -104,7 +104,7 @@ def updateChannelFinder(
104104
)
105105
)
106106
pvNames.remove(ch["name"])
107-
elif pvNames == None or ch["name"] not in pvNames:
107+
elif pvNames is None or ch["name"] not in pvNames:
108108
"""Orphan the channel : mark as inactive, keep the old hostName and iocName"""
109109
oldHostName = [
110110
prop["value"]
@@ -141,7 +141,7 @@ def updateChannelFinder(
141141
time=time,
142142
)
143143
)
144-
elif ch[0] != None:
144+
elif ch[0] is not None:
145145
"""update existing channel: exists but with a different hostName and/or iocName"""
146146
channels.append(
147147
updateChannel(
@@ -174,9 +174,9 @@ def updateChannel(
174174
]
175175
else:
176176
properties = []
177-
if hostName != None:
177+
if hostName is not None:
178178
properties.append({"name": "hostName", "owner": owner, "value": hostName})
179-
if iocName != None:
179+
if iocName is not None:
180180
properties.append({"name": "iocName", "owner": owner, "value": iocName})
181181
if pvStatus:
182182
properties.append({"name": "pvStatus", "owner": owner, "value": pvStatus})
@@ -193,11 +193,11 @@ def createChannel(
193193
Helper to create a channel object with the required properties
194194
"""
195195
ch = {"name": chName, "owner": chOwner, "properties": []}
196-
if hostName != None:
196+
if hostName is not None:
197197
ch["properties"].append(
198198
{"name": "hostName", "owner": chOwner, "value": hostName}
199199
)
200-
if iocName != None:
200+
if iocName is not None:
201201
ch["properties"].append({"name": "iocName", "owner": chOwner, "value": iocName})
202202
if pvStatus:
203203
ch["properties"].append(
@@ -214,7 +214,7 @@ def checkPropertiesExist(client, propOwner):
214214
"""
215215
requiredProperties = ["hostName", "iocName", "pvStatus", "time"]
216216
for propName in requiredProperties:
217-
if client.findProperty(propName) == None:
217+
if client.findProperty(propName) is None:
218218
try:
219219
client.set(property={"name": propName, "owner": propOwner})
220220
except Exception as e:
@@ -226,7 +226,7 @@ def ifNoneReturnDefault(object, default):
226226
"""
227227
if the object is None or empty string then this function returns the default value
228228
"""
229-
if object == None and object != "":
229+
if object is None or object == "":
230230
return default
231231
else:
232232
return object
@@ -348,7 +348,7 @@ def main():
348348
help="prompt user for password",
349349
)
350350
opts, args = parser.parse_args()
351-
if len(args) == 0 or args == None:
351+
if not args:
352352
parser.error("Please specify a file")
353353
mainRun(opts, args)
354354

test/testCFPpropertyManager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_regex(self):
8080
print(properties[0] + " = " + properties[1])
8181
try:
8282
expression = re.compile(properties[1])
83-
self.assertTrue(expression != None)
83+
self.assertTrue(expression is not None)
8484

8585
except Exception as e:
8686
print("Invalid regular expression: ", properties[1])

test/testCFUpdateIOC.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def testGetArgsFromFilename(self):
6363
# parse file which does not fit the format
6464
hostname, iocname = getArgsFromFilename("complete/path/to/file/somefilename")
6565
self.assertTrue(
66-
hostname == None and iocname == None,
66+
hostname is None and iocname is None,
6767
"failed to parse the file path correctly",
6868
)
6969
# file with only hostName
7070
hostname, iocname = getArgsFromFilename(
7171
"complete/path/to/file/aaa.somefilename"
7272
)
7373
self.assertTrue(
74-
hostname == "aaa" and iocname == None, "failed to parse the file correctly"
74+
hostname == "aaa" and iocname is None, "failed to parse the file correctly"
7575
)
7676
# parse the hostname/iocname from 1st and 2nd positions seperated by .
7777
hostname, iocname = getArgsFromFilename("complete/path/to/file/aaa.bbb.ccc.ddd")
@@ -96,7 +96,7 @@ def testAddUpdateChannels(self):
9696
property=[("hostName", hostName1), ("iocName", iocName1)]
9797
)
9898
self.assertTrue(
99-
channels == None or len(channels) == 0, "channels already present"
99+
not channels, "channels already present"
100100
)
101101
# New Channels added
102102
updateChannelFinder(
@@ -427,7 +427,7 @@ def __check4properties(self, prop, properties):
427427
def testNoneCheck(self):
428428
self.assertTrue(ifNoneReturnDefault("Value", "default") == "Value")
429429
self.assertTrue(ifNoneReturnDefault(None, "default") == "default")
430-
self.assertTrue(ifNoneReturnDefault(None, None) == None)
430+
self.assertTrue(ifNoneReturnDefault(None, None) is None)
431431
self.assertTrue(ifNoneReturnDefault("", "default") == "")
432432

433433
def testPVUpdate(self):

test/testChannelFinderClient.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,9 @@ def testSetRemoveSpecialChar(self):
840840
"failed to delete channel with special char",
841841
)
842842
self.client.delete(tagName=spTag["name"])
843-
self.assertTrue(self.client.findTag(spTag["name"]) == None)
843+
self.assertTrue(self.client.findTag(spTag["name"]) is None)
844844
self.client.delete(propertyName=spProperty["name"])
845-
self.assertTrue(self.client.findProperty(spProperty["name"]) == None)
845+
self.assertTrue(self.client.findProperty(spProperty["name"]) is None)
846846

847847
def testQuotes(self):
848848
spChannel = {"name": "'\"Name", "owner": self.channelOwner}
@@ -1700,7 +1700,7 @@ def testUpdateChannelWithNullPropertyValue(self):
17001700
},
17011701
)
17021702
print("client: " + str(self.client.find(name="channelName")[0]))
1703-
# should this/ be if client.find... == None ???
1703+
# should this/ be if client.find... is None ???
17041704
self.assertFalse(
17051705
"existingProperty"
17061706
in self.client.find(name="channelName")[0]["properties"],
@@ -1802,7 +1802,7 @@ def checkTagOnChannel(client, channelName, tag):
18021802
utility method which return true is channelName contains tag
18031803
"""
18041804
ch = client.find(name=channelName)[0]
1805-
if ch["tags"] != None and checkTagInList(ch["tags"], [tag]):
1805+
if ch["tags"] is not None and checkTagInList(ch["tags"], [tag]):
18061806
return True
18071807
else:
18081808
return False
@@ -1813,7 +1813,7 @@ def checkPropertyOnChannel(client, channelName, property):
18131813
utility method which return true is channelName contains property
18141814
"""
18151815
ch = client.find(name=channelName)[0]
1816-
if ch["properties"] != None and checkPropInList(ch["properties"], [property]):
1816+
if ch["properties"] is not None and checkPropInList(ch["properties"], [property]):
18171817
return True
18181818
else:
18191819
return False

0 commit comments

Comments
 (0)