From 8ca613e43fe9078676afbebf7ccf1eef9f1f3387 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Thu, 26 Mar 2020 05:40:28 -0500 Subject: [PATCH] Raise hacking to 2.x We have kept hacking capped below 1.2 for quite awhile. Newer versions of hacking pull in updated linters that have some good checks. We want to limit the maximum version of hacking installed since the global upper constraints does not do this for linters. Otherwise when a new release of hacking is available in the future, stable branches may suddenly be broken. Change-Id: I0e0ee8a169ae93f7efb2cda2b1d2458c1d49e46b Signed-off-by: Sean McGinnis --- openstack/__init__.py | 5 +-- openstack/baremetal/v1/node.py | 4 +-- openstack/cloud/_dns.py | 2 +- openstack/cloud/_identity.py | 2 +- openstack/config/cloud_region.py | 2 +- openstack/network/v2/_proxy.py | 2 +- openstack/tests/unit/compute/v2/test_proxy.py | 34 +++++++++---------- test-requirements.txt | 2 +- tools/print-services.py | 1 + 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/openstack/__init__.py b/openstack/__init__.py index 06aa5236d..e7827c5d6 100644 --- a/openstack/__init__.py +++ b/openstack/__init__.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import typing from openstack._log import enable_logging # noqa import openstack.config @@ -24,8 +25,8 @@ __all__ = [ def connect( cloud=None, - app_name=None, # type: Optional[str] - app_version=None, # type: Optional[str] + app_name=None, # type: typing.Optional[str] + app_version=None, # type: typing.Optional[str] options=None, load_yaml_config=True, # type: bool load_envvars=True, # type: bool diff --git a/openstack/baremetal/v1/node.py b/openstack/baremetal/v1/node.py index c2bd09d60..5c034e723 100644 --- a/openstack/baremetal/v1/node.py +++ b/openstack/baremetal/v1/node.py @@ -515,8 +515,8 @@ class Node(_common.ListMixin, resource.Resource): elif not abort_on_failed_state: return False - if (self.provision_state.endswith(' failed') or - self.provision_state == 'error'): + if (self.provision_state.endswith(' failed') + or self.provision_state == 'error'): raise exceptions.ResourceFailure( "Node %(node)s reached failure state \"%(state)s\"; " "the last error is %(error)s" % diff --git a/openstack/cloud/_dns.py b/openstack/cloud/_dns.py index b663b06c7..8c4ce4427 100644 --- a/openstack/cloud/_dns.py +++ b/openstack/cloud/_dns.py @@ -100,7 +100,7 @@ class DnsCloudMixin(_normalize.Normalizer): try: return self.dns.create_zone(**zone) - except exceptions.SDKException as e: + except exceptions.SDKException: raise exc.OpenStackCloudException( "Unable to create zone {name}".format(name=name) ) diff --git a/openstack/cloud/_identity.py b/openstack/cloud/_identity.py index e03a1ed6a..af94c8a87 100644 --- a/openstack/cloud/_identity.py +++ b/openstack/cloud/_identity.py @@ -209,7 +209,7 @@ class IdentityCloudMixin(_normalize.Normalizer): # side filter for user name https://bit.ly/2qh0Ijk # especially important when using LDAP and using page to limit results if name_or_id and not _utils._is_uuid_like(name_or_id): - kwargs['name'] = name_or_id + kwargs['name'] = name_or_id users = self.list_users(**kwargs) return _utils._filter_list(users, name_or_id, filters) diff --git a/openstack/config/cloud_region.py b/openstack/config/cloud_region.py index 6862230f8..96a126381 100644 --- a/openstack/config/cloud_region.py +++ b/openstack/config/cloud_region.py @@ -501,7 +501,7 @@ class CloudRegion(object): and self.config.get('profile') == 'rackspace' and service_type == 'block-storage' ): - value = value + auth.get('project_id') + value = value + auth.get('project_id') return value def get_endpoint_from_catalog( diff --git a/openstack/network/v2/_proxy.py b/openstack/network/v2/_proxy.py index 68834a61c..1b4a40534 100644 --- a/openstack/network/v2/_proxy.py +++ b/openstack/network/v2/_proxy.py @@ -3976,7 +3976,7 @@ class Proxy(proxy.Proxy): :param floating_ip: The value can be the ID of the Floating IP that the port forwarding belongs or a :class:`~openstack. network.v2.floating_ip.FloatingIP` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs **query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of floating ip port forwarding objects :rtype: :class:`~openstack.network.v2.port_forwarding. diff --git a/openstack/tests/unit/compute/v2/test_proxy.py b/openstack/tests/unit/compute/v2/test_proxy.py index 64d025c58..c1757c890 100644 --- a/openstack/tests/unit/compute/v2/test_proxy.py +++ b/openstack/tests/unit/compute/v2/test_proxy.py @@ -454,27 +454,27 @@ class TestComputeProxy(test_proxy_base.TestProxyBase): with mock.patch('openstack.compute.v2.server.Server.create_image') \ as ci_mock: - ci_mock.return_value = 'image_id' - connection_mock = mock.Mock() - connection_mock.get_image = mock.Mock(return_value='image') - connection_mock.wait_for_image = mock.Mock() - self.proxy._connection = connection_mock + ci_mock.return_value = 'image_id' + connection_mock = mock.Mock() + connection_mock.get_image = mock.Mock(return_value='image') + connection_mock.wait_for_image = mock.Mock() + self.proxy._connection = connection_mock - rsp = self.proxy.create_server_image( - 'server', 'image_name', metadata, wait=True, timeout=1) + rsp = self.proxy.create_server_image( + 'server', 'image_name', metadata, wait=True, timeout=1) - ci_mock.assert_called_with( - self.proxy, - 'image_name', - metadata - ) + ci_mock.assert_called_with( + self.proxy, + 'image_name', + metadata + ) - self.proxy._connection.get_image.assert_called_with('image_id') - self.proxy._connection.wait_for_image.assert_called_with( - 'image', - timeout=1) + self.proxy._connection.get_image.assert_called_with('image_id') + self.proxy._connection.wait_for_image.assert_called_with( + 'image', + timeout=1) - self.assertEqual(connection_mock.wait_for_image(), rsp) + self.assertEqual(connection_mock.wait_for_image(), rsp) def test_server_group_create(self): self.verify_create(self.proxy.create_server_group, diff --git a/test-requirements.txt b/test-requirements.txt index bbd290487..ad440b8cc 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.0,<1.2 # Apache-2.0 +hacking>=2.0,<2.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 ddt>=1.0.1 # MIT diff --git a/tools/print-services.py b/tools/print-services.py index 33872acd1..b4c664957 100644 --- a/tools/print-services.py +++ b/tools/print-services.py @@ -125,4 +125,5 @@ def _find_service_description_class(service_type): service_description_class = getattr(service_description_module, class_name) return service_description_class + make_names()