Skip to content

Commit 3973fc3

Browse files
committed
Bump hacking version
This bumps the version of flake8 and resolves some erroneous failures in f-strings. A number of new E721 (do not compare types) class errors are picked up, which are all addressed. Change-Id: I7a1937b107ff3af8d1e5fe23fc32b120ef4697f7 Signed-off-by: Stephen Finucane <[email protected]>
1 parent 8525425 commit 3973fc3

File tree

10 files changed

+17
-21
lines changed

10 files changed

+17
-21
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
- id: remove-tabs
2525
exclude: '.*\.(svg)$'
2626
- repo: https://opendev.org/openstack/hacking
27-
rev: 6.0.1
27+
rev: 6.1.0
2828
hooks:
2929
- id: hacking
3030
additional_dependencies: []

nova/compute/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,7 @@ def snapshot(self, context, instance, name, extra_properties=None):
33903390
"error_msg": str(exc)})
33913391
attr = 'task_state'
33923392
state = task_states.DELETING
3393-
if type(ex) == exception.InstanceNotFound:
3393+
if type(ex) is exception.InstanceNotFound:
33943394
attr = 'vm_state'
33953395
state = vm_states.DELETED
33963396
raise exception.InstanceInvalidState(attr=attr,

nova/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,10 @@ def __init__(self, wanttype):
820820
self.wanttype = wanttype
821821

822822
def __eq__(self, other):
823-
return type(other) == self.wanttype
823+
return type(other) is self.wanttype
824824

825825
def __ne__(self, other):
826-
return type(other) != self.wanttype
826+
return type(other) is not self.wanttype
827827

828828
def __repr__(self):
829829
return "<MatchType:" + str(self.wanttype) + ">"

nova/tests/fixtures/libvirt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,10 +2157,10 @@ def listAllDevices(self, flags):
21572157

21582158
def openAuth(uri, auth, flags=0):
21592159

2160-
if type(auth) != list:
2160+
if type(auth) is not list:
21612161
raise Exception("Expected a list for 'auth' parameter")
21622162

2163-
if type(auth[0]) != list:
2163+
if type(auth[0]) is not list:
21642164
raise Exception("Expected a function in 'auth[0]' parameter")
21652165

21662166
if not callable(auth[1]):

nova/tests/unit/compute/test_compute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12918,7 +12918,7 @@ def __init__(self, aggr):
1291812918
self.aggr = aggr
1291912919

1292012920
def __eq__(self, other_aggr):
12921-
if type(self.aggr) != type(other_aggr):
12921+
if type(self.aggr) is not type(other_aggr):
1292212922
return False
1292312923
return self.aggr.id == other_aggr.id
1292412924

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7727,7 +7727,7 @@ def test_get_guest_config_with_pci_passthrough_kvm(self):
77277727
had_pci = 0
77287728
# care only about the PCI devices
77297729
for dev in cfg.devices:
7730-
if type(dev) == vconfig.LibvirtConfigGuestHostdevPCI:
7730+
if type(dev) is vconfig.LibvirtConfigGuestHostdevPCI:
77317731
had_pci += 1
77327732
self.assertEqual(dev.type, 'pci')
77337733
self.assertEqual(dev.managed, 'yes')
@@ -13473,7 +13473,7 @@ def fake_job_info():
1347313473
self.assertGreater(len(job_info_records), 0)
1347413474
rec = job_info_records.pop(0)
1347513475

13476-
if type(rec) == str:
13476+
if type(rec) is str:
1347713477
if rec == "thread-finish":
1347813478
finish_event.send()
1347913479
elif rec == "domain-stop":
@@ -14149,7 +14149,7 @@ def fake_recover():
1414914149

1415014150
class AnyEventletEvent(object):
1415114151
def __eq__(self, other):
14152-
return type(other) == eventlet.event.Event
14152+
return type(other) is eventlet.event.Event
1415314153

1415414154
mock_thread.assert_called_once_with(
1415514155
drvr._live_migration_operation,

nova/tests/unit/virt/test_hardware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def test_validate_config(self):
399399

400400
for topo_test in testdata:
401401
image_meta = objects.ImageMeta.from_dict(topo_test["image"])
402-
if type(topo_test["expect"]) == tuple:
402+
if type(topo_test["expect"]) is tuple:
403403
(preferred, maximum) = hw.get_cpu_topology_constraints(
404404
topo_test["flavor"], image_meta)
405405

@@ -525,7 +525,7 @@ def test_possible_topologies(self):
525525
]
526526

527527
for topo_test in testdata:
528-
if type(topo_test["expect"]) == list:
528+
if type(topo_test["expect"]) is list:
529529
actual = []
530530
for topology in hw._get_possible_cpu_topologies(
531531
topo_test["vcpus"],
@@ -1001,7 +1001,7 @@ def test_cpu_policy_constraint(self):
10011001
cpu_policy = hw.get_cpu_policy_constraint(
10021002
testitem["flavor"], image_meta)
10031003
self.assertIsNone(cpu_policy)
1004-
elif type(testitem["expect"]) == type:
1004+
elif type(testitem["expect"]) is type:
10051005
self.assertRaises(testitem["expect"],
10061006
hw.get_cpu_policy_constraint,
10071007
testitem["flavor"],
@@ -1990,7 +1990,7 @@ def test_topology_constraints(self):
19901990
topology = hw.numa_get_constraints(
19911991
testitem["flavor"], image_meta)
19921992
self.assertIsNone(topology)
1993-
elif type(testitem["expect"]) == type:
1993+
elif type(testitem["expect"]) is type:
19941994
self.assertRaises(testitem["expect"],
19951995
hw.numa_get_constraints,
19961996
testitem["flavor"],

nova/virt/libvirt/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def parse_dom(self, xmldoc):
269269

270270
def _get_device(self, device_type):
271271
for device in self.devices:
272-
if type(device) == self.DEVICE_PARSERS.get(device_type):
272+
if type(device) is self.DEVICE_PARSERS.get(device_type):
273273
return device
274274
return None
275275

nova/virt/libvirt/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,7 @@ def snapshot(self, context, instance, image_id, update_task_state):
31143114
purge_props=False)
31153115
except (NotImplementedError, exception.ImageUnacceptable,
31163116
exception.Forbidden) as e:
3117-
if type(e) != NotImplementedError:
3117+
if type(e) is not NotImplementedError:
31183118
LOG.warning('Performing standard snapshot because direct '
31193119
'snapshot failed: %(error)s',
31203120
{'error': encodeutils.exception_to_unicode(e)})

test-requirements.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# The order of packages is significant, because pip processes them in the order
2-
# of appearance. Changing the order has an impact on the overall integration
3-
# process, which may cause wedges in the gate later.
4-
5-
hacking>=6.0.1,<=6.0.1 # Apache-2.0
1+
hacking==6.1.0 # Apache-2.0
62
mypy>=0.761 # MIT
73
types-paramiko>=0.1.3 # Apache-2.0
84
coverage!=4.4,>=4.0 # Apache-2.0

0 commit comments

Comments
 (0)