From 298c5107ebde0850379970a7f3678b057ed90a93 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 7 Feb 2020 11:39:24 +0000 Subject: [PATCH] Bump to hacking 2.x This allows us to use a new version of flake8 that supports Python 3-only syntax. Existing issues are resolved. Change-Id: I5de7e5cde6a5260f4e7e57586952256b59d3756d Signed-off-by: Stephen Finucane --- oslo_versionedobjects/examples/iot_bulb.py | 1 + oslo_versionedobjects/fields.py | 6 ++---- oslo_versionedobjects/test.py | 1 + test-requirements.txt | 2 +- tox.ini | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oslo_versionedobjects/examples/iot_bulb.py b/oslo_versionedobjects/examples/iot_bulb.py index b5160bc9..4ef0f62e 100644 --- a/oslo_versionedobjects/examples/iot_bulb.py +++ b/oslo_versionedobjects/examples/iot_bulb.py @@ -40,6 +40,7 @@ class IOTLightbulb(base.VersionedObject): 'manufactured_on': obj_fields.DateTimeField(), } + # Now do some basic operations on a light bulb. bulb = IOTLightbulb(serial='abc-123', manufactured_on=datetime.now()) print("The __str__() output of this new object: %s" % bulb) diff --git a/oslo_versionedobjects/fields.py b/oslo_versionedobjects/fields.py index 4952d8db..21d85039 100644 --- a/oslo_versionedobjects/fields.py +++ b/oslo_versionedobjects/fields.py @@ -1255,8 +1255,7 @@ class CoercedList(CoercedCollectionMixin, list): super(CoercedList, self).append(self._coerce_item(len(self) + 1, x)) def extend(self, t): - l = len(self) - coerced_items = [self._coerce_item(l + index, item) + coerced_items = [self._coerce_item(len(self) + index, item) for index, item in enumerate(t)] super(CoercedList, self).extend(coerced_items) @@ -1264,8 +1263,7 @@ class CoercedList(CoercedCollectionMixin, list): super(CoercedList, self).insert(i, self._coerce_item(i, x)) def __iadd__(self, y): - l = len(self) - coerced_items = [self._coerce_item(l + index, item) + coerced_items = [self._coerce_item(len(self) + index, item) for index, item in enumerate(y)] return super(CoercedList, self).__iadd__(coerced_items) diff --git a/oslo_versionedobjects/test.py b/oslo_versionedobjects/test.py index e17d5cd7..3a34b82d 100644 --- a/oslo_versionedobjects/test.py +++ b/oslo_versionedobjects/test.py @@ -95,6 +95,7 @@ def _patch_mock_to_raise_for_invalid_assert_calls(): mock.Mock.__getattr__ = raise_for_invalid_assert_calls( mock.Mock.__getattr__) + # NOTE(gibi): needs to be called only once at import time # to patch the mock lib _patch_mock_to_raise_for_invalid_assert_calls() diff --git a/test-requirements.txt b/test-requirements.txt index 961f99ce..f7840885 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=2.0.0,<2.1.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 testtools>=2.2.0 # MIT coverage!=4.4,>=4.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index cd1ba566..84cdcdd2 100644 --- a/tox.ini +++ b/tox.ini @@ -46,8 +46,9 @@ deps = [flake8] # E123, E125 skipped as they are invalid PEP-8. +# W504 skipped as you must choose this or W503 show-source = True -ignore = E123,E125 +ignore = E123,E125,W504 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build