Stop subclassing object
This wasn't actually even needed in python2.7, but habits die hard. Change-Id: I20f282d285506b1f1dde01be6cde0c0e8c7883c8
This commit is contained in:
parent
2ddbf57ee6
commit
0c5ae59025
@ -36,7 +36,7 @@ config = loader.OpenStackConfig()
|
||||
cloud = openstack.connect(cloud=TEST_CLOUD)
|
||||
|
||||
|
||||
class Opts(object):
|
||||
class Opts:
|
||||
def __init__(self, cloud_name='devstack-admin', debug=False):
|
||||
self.cloud = cloud_name
|
||||
self.debug = debug
|
||||
|
@ -20,7 +20,7 @@ from openstack.orchestration import orchestration_service
|
||||
from openstack.workflow import workflow_service
|
||||
|
||||
|
||||
class ServicesMixin(object):
|
||||
class ServicesMixin:
|
||||
|
||||
identity = identity_service.IdentityService(service_type='identity')
|
||||
|
||||
|
@ -68,7 +68,7 @@ CONFIG_DRIVE_DICT_VERSION = '1.56'
|
||||
"""API version in which configdrive can be a dictionary."""
|
||||
|
||||
|
||||
class ListMixin(object):
|
||||
class ListMixin:
|
||||
|
||||
@classmethod
|
||||
def list(cls, session, details=False, **params):
|
||||
|
@ -18,7 +18,7 @@ from openstack import resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class ValidationResult(object):
|
||||
class ValidationResult:
|
||||
"""Result of a single interface validation.
|
||||
|
||||
:ivar result: Result of a validation, ``True`` for success, ``False`` for
|
||||
|
@ -139,7 +139,7 @@ def _pop_or_get(resource, key, default, strict):
|
||||
return resource.get(key, default)
|
||||
|
||||
|
||||
class Normalizer(object):
|
||||
class Normalizer:
|
||||
'''Mix-in class to provide the normalization functions.
|
||||
|
||||
This is in a separate class just for on-disk source code organization
|
||||
|
@ -667,7 +667,7 @@ def generate_patches_from_kwargs(operation, **kwargs):
|
||||
return sorted(patches)
|
||||
|
||||
|
||||
class FileSegment(object):
|
||||
class FileSegment:
|
||||
"""File-like object to pass to requests."""
|
||||
|
||||
def __init__(self, filename, offset, length):
|
||||
|
@ -22,7 +22,7 @@ from openstack.cloud import _utils
|
||||
__all__ = ['OpenStackInventory']
|
||||
|
||||
|
||||
class OpenStackInventory(object):
|
||||
class OpenStackInventory:
|
||||
|
||||
# Put this here so the capability can be detected with hasattr on the class
|
||||
extra_config = None
|
||||
|
@ -48,7 +48,7 @@ DEFAULT_MAX_FILE_SIZE = _object_store.DEFAULT_MAX_FILE_SIZE
|
||||
OBJECT_CONTAINER_ACLS = _object_store.OBJECT_CONTAINER_ACLS
|
||||
|
||||
|
||||
class _OpenStackCloudMixin(object):
|
||||
class _OpenStackCloudMixin:
|
||||
"""Represent a connection to an OpenStack Cloud.
|
||||
|
||||
OpenStackCloud is the entry point for all cloud operations, regardless
|
||||
@ -126,7 +126,7 @@ class _OpenStackCloudMixin(object):
|
||||
def _fake_invalidate(unused):
|
||||
pass
|
||||
|
||||
class _FakeCache(object):
|
||||
class _FakeCache:
|
||||
def invalidate(self):
|
||||
pass
|
||||
|
||||
|
@ -15,7 +15,7 @@ from openstack import exceptions
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class MetadataMixin(object):
|
||||
class MetadataMixin:
|
||||
|
||||
def _metadata(self, method, key=None, clear=False, delete=False,
|
||||
metadata=None):
|
||||
|
@ -45,7 +45,7 @@ def merge_clouds(old_dict, new_dict):
|
||||
return ret
|
||||
|
||||
|
||||
class VersionRequest(object):
|
||||
class VersionRequest:
|
||||
def __init__(
|
||||
self,
|
||||
version=None,
|
||||
|
@ -201,7 +201,7 @@ def from_conf(conf, session=None, service_types=None, **kwargs):
|
||||
session=session, config=config_dict, **kwargs)
|
||||
|
||||
|
||||
class CloudRegion(object):
|
||||
class CloudRegion:
|
||||
# TODO(efried): Doc the rest of the kwargs
|
||||
"""The configuration for a Region of an OpenStack Cloud.
|
||||
|
||||
|
@ -127,7 +127,7 @@ def _fix_argv(argv):
|
||||
options=','.join(overlap)))
|
||||
|
||||
|
||||
class OpenStackConfig(object):
|
||||
class OpenStackConfig:
|
||||
|
||||
# These two attribute are to allow os-client-config to plumb in its
|
||||
# local versions for backwards compat.
|
||||
|
@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
class Formatter(object):
|
||||
class Formatter:
|
||||
|
||||
@classmethod
|
||||
def serialize(cls, value):
|
||||
|
@ -24,7 +24,7 @@ def _verify_checksum(md5, checksum):
|
||||
"checksum mismatch: %s != %s" % (checksum, digest))
|
||||
|
||||
|
||||
class DownloadMixin(object):
|
||||
class DownloadMixin:
|
||||
|
||||
def download(self, session, stream=False, output=None, chunk_size=1024):
|
||||
"""Download the data contained in an image"""
|
||||
|
@ -28,7 +28,7 @@ HASH_METHODS = {
|
||||
}
|
||||
|
||||
|
||||
class ImageSigner(object):
|
||||
class ImageSigner:
|
||||
"""Image file signature generator.
|
||||
|
||||
Generates signatures for files using a specified private key file.
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
|
||||
|
||||
class IterableChunkedFile(object):
|
||||
class IterableChunkedFile:
|
||||
"""File object chunk iterator using yield.
|
||||
|
||||
Represents a local file as an iterable object by splitting the file
|
||||
|
@ -82,7 +82,7 @@ def _convert_type(value, data_type, list_type=None):
|
||||
return data_type(value)
|
||||
|
||||
|
||||
class _BaseComponent(object):
|
||||
class _BaseComponent:
|
||||
|
||||
# The name this component is being tracked as in the Resource
|
||||
key = None
|
||||
@ -257,7 +257,7 @@ class _ComponentManager(collections.MutableMapping):
|
||||
self._dirty = set()
|
||||
|
||||
|
||||
class _Request(object):
|
||||
class _Request:
|
||||
"""Prepared components that go into a KSA request"""
|
||||
|
||||
def __init__(self, url, body, headers):
|
||||
@ -266,7 +266,7 @@ class _Request(object):
|
||||
self.headers = headers
|
||||
|
||||
|
||||
class QueryParameters(object):
|
||||
class QueryParameters:
|
||||
|
||||
def __init__(self, *names, **mappings):
|
||||
"""Create a dict of accepted query parameters
|
||||
@ -1862,7 +1862,7 @@ class Resource(dict):
|
||||
"No %s found for %s" % (cls.__name__, name_or_id))
|
||||
|
||||
|
||||
class TagMixin(object):
|
||||
class TagMixin:
|
||||
|
||||
_tag_query_parameters = {
|
||||
'tags': 'tags',
|
||||
|
@ -27,7 +27,7 @@ _logger = _log.setup_logging('openstack')
|
||||
_service_type_manager = os_service_types.ServiceTypes()
|
||||
|
||||
|
||||
class _ServiceDisabledProxyShim(object):
|
||||
class _ServiceDisabledProxyShim:
|
||||
def __init__(self, service_type, reason):
|
||||
self.service_type = service_type
|
||||
self.reason = reason
|
||||
@ -39,7 +39,7 @@ class _ServiceDisabledProxyShim(object):
|
||||
service_type=self.service_type, reason=self.reason or ''))
|
||||
|
||||
|
||||
class ServiceDescription(object):
|
||||
class ServiceDescription:
|
||||
|
||||
#: Dictionary of supported versions and proxy classes for that version
|
||||
supported_versions = None
|
||||
|
@ -282,7 +282,7 @@ def make_fake_port(address, node_id=None, port_id=None):
|
||||
node_id=node_id))
|
||||
|
||||
|
||||
class FakeFloatingIP(object):
|
||||
class FakeFloatingIP:
|
||||
def __init__(self, id, pool, ip, fixed_ip, instance_id):
|
||||
self.id = id
|
||||
self.pool = pool
|
||||
@ -345,7 +345,7 @@ def make_fake_hypervisor(id, name):
|
||||
}))
|
||||
|
||||
|
||||
class FakeVolume(object):
|
||||
class FakeVolume:
|
||||
def __init__(
|
||||
self, id, status, name, attachments=[],
|
||||
size=75):
|
||||
@ -363,7 +363,7 @@ class FakeVolume(object):
|
||||
self.metadata = {}
|
||||
|
||||
|
||||
class FakeVolumeSnapshot(object):
|
||||
class FakeVolumeSnapshot:
|
||||
def __init__(
|
||||
self, id, status, name, description, size=75):
|
||||
self.id = id
|
||||
@ -376,7 +376,7 @@ class FakeVolumeSnapshot(object):
|
||||
self.metadata = {}
|
||||
|
||||
|
||||
class FakeMachine(object):
|
||||
class FakeMachine:
|
||||
def __init__(self, id, name=None, driver=None, driver_info=None,
|
||||
chassis_uuid=None, instance_info=None, instance_uuid=None,
|
||||
properties=None, reservation=None, last_error=None,
|
||||
@ -394,7 +394,7 @@ class FakeMachine(object):
|
||||
self.provision_state = provision_state
|
||||
|
||||
|
||||
class FakeMachinePort(object):
|
||||
class FakeMachinePort:
|
||||
def __init__(self, id, address, node_id):
|
||||
self.uuid = id
|
||||
self.address = address
|
||||
@ -443,7 +443,7 @@ def make_fake_nova_security_group(id, name, description, rules):
|
||||
}))
|
||||
|
||||
|
||||
class FakeNovaSecgroupRule(object):
|
||||
class FakeNovaSecgroupRule:
|
||||
def __init__(self, id, from_port=None, to_port=None, ip_protocol=None,
|
||||
cidr=None, parent_group_id=None):
|
||||
self.id = id
|
||||
@ -455,13 +455,13 @@ class FakeNovaSecgroupRule(object):
|
||||
self.parent_group_id = parent_group_id
|
||||
|
||||
|
||||
class FakeHypervisor(object):
|
||||
class FakeHypervisor:
|
||||
def __init__(self, id, hostname):
|
||||
self.id = id
|
||||
self.hypervisor_hostname = hostname
|
||||
|
||||
|
||||
class FakeZone(object):
|
||||
class FakeZone:
|
||||
def __init__(self, id, name, type_, email, description,
|
||||
ttl, masters):
|
||||
self.id = id
|
||||
@ -473,7 +473,7 @@ class FakeZone(object):
|
||||
self.masters = masters
|
||||
|
||||
|
||||
class FakeRecordset(object):
|
||||
class FakeRecordset:
|
||||
def __init__(self, zone, id, name, type_, description,
|
||||
ttl, records):
|
||||
self.zone = zone
|
||||
|
@ -18,7 +18,7 @@ TEST_IMAGE_NAME = 'Test Image'
|
||||
|
||||
class TestImage(base.BaseFunctionalTest):
|
||||
|
||||
class ImageOpts(object):
|
||||
class ImageOpts:
|
||||
def __init__(self):
|
||||
self.image_api_version = '2'
|
||||
|
||||
|
@ -24,13 +24,13 @@ PUBLIC_V4 = '192.0.2.99'
|
||||
PUBLIC_V6 = '2001:0db8:face:0da0:face::0b00:1c' # rfc3849
|
||||
|
||||
|
||||
class FakeConfig(object):
|
||||
class FakeConfig:
|
||||
def get_region_name(self, service_type=None):
|
||||
# TODO(efried): Validate service_type?
|
||||
return 'test-region'
|
||||
|
||||
|
||||
class FakeCloud(object):
|
||||
class FakeCloud:
|
||||
config = FakeConfig()
|
||||
name = 'test-name'
|
||||
private = False
|
||||
@ -942,10 +942,10 @@ class TestMeta(base.TestCase):
|
||||
|
||||
def test_obj_list_to_munch(self):
|
||||
"""Test conversion of a list of objects to a list of dictonaries"""
|
||||
class obj0(object):
|
||||
class obj0:
|
||||
value = 0
|
||||
|
||||
class obj1(object):
|
||||
class obj1:
|
||||
value = 1
|
||||
|
||||
list = [obj0, obj1]
|
||||
|
@ -26,7 +26,7 @@ zone_dict = {
|
||||
}
|
||||
|
||||
|
||||
class ZoneTestWrapper(object):
|
||||
class ZoneTestWrapper:
|
||||
|
||||
def __init__(self, ut, attrs):
|
||||
self.remote_res = attrs
|
||||
|
@ -806,7 +806,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_no_force(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = None
|
||||
max_microversion = None
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
@ -822,7 +822,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_no_microversion_force_true(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = None
|
||||
max_microversion = None
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
@ -848,7 +848,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_25(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = '2.1'
|
||||
max_microversion = '2.25'
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
@ -872,7 +872,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_25_default_block(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = '2.1'
|
||||
max_microversion = '2.25'
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
@ -896,7 +896,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_30(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = '2.1'
|
||||
max_microversion = '2.30'
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
@ -920,7 +920,7 @@ class TestServer(base.TestCase):
|
||||
def test_live_migrate_30_force(self):
|
||||
sot = server.Server(**EXAMPLE)
|
||||
|
||||
class FakeEndpointData(object):
|
||||
class FakeEndpointData:
|
||||
min_microversion = '2.1'
|
||||
max_microversion = '2.30'
|
||||
self.sess.get_endpoint_data.return_value = FakeEndpointData()
|
||||
|
@ -95,7 +95,7 @@ def calculate_md5_checksum(data):
|
||||
return checksum.hexdigest()
|
||||
|
||||
|
||||
class FakeResponse(object):
|
||||
class FakeResponse:
|
||||
def __init__(self, response, status_code=200, headers=None, reason=None):
|
||||
self.body = response
|
||||
self.content = response
|
||||
|
@ -27,7 +27,7 @@ from openstack.tests.unit import test_proxy_base
|
||||
EXAMPLE = fake_image.EXAMPLE
|
||||
|
||||
|
||||
class FakeResponse(object):
|
||||
class FakeResponse:
|
||||
def __init__(self, response, status_code=200, headers=None):
|
||||
self.body = response
|
||||
self.status_code = status_code
|
||||
|
@ -137,7 +137,7 @@ class TestProxyPrivate(base.TestCase):
|
||||
# of that same behavior to let us check that `new` gets
|
||||
# called with the expected arguments.
|
||||
|
||||
class Fake(object):
|
||||
class Fake:
|
||||
call = {}
|
||||
|
||||
@classmethod
|
||||
|
@ -24,7 +24,7 @@ from openstack import resource
|
||||
from openstack.tests.unit import base
|
||||
|
||||
|
||||
class FakeResponse(object):
|
||||
class FakeResponse:
|
||||
def __init__(self, response, status_code=200, headers=None):
|
||||
self.body = response
|
||||
self.status_code = status_code
|
||||
@ -74,7 +74,7 @@ class TestComponent(base.TestCase):
|
||||
def test_get_name_None(self):
|
||||
name = "name"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {name: None}
|
||||
|
||||
instance = Parent()
|
||||
@ -87,7 +87,7 @@ class TestComponent(base.TestCase):
|
||||
def test_get_default(self):
|
||||
expected_result = 123
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {}
|
||||
|
||||
instance = Parent()
|
||||
@ -104,7 +104,7 @@ class TestComponent(base.TestCase):
|
||||
name = "name"
|
||||
expected_result = 123
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {name: expected_result}
|
||||
|
||||
instance = Parent()
|
||||
@ -119,7 +119,7 @@ class TestComponent(base.TestCase):
|
||||
name = "name"
|
||||
value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {name: value}
|
||||
|
||||
instance = Parent()
|
||||
@ -134,7 +134,7 @@ class TestComponent(base.TestCase):
|
||||
value = "123"
|
||||
expected_result = "one hundred twenty three"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {name: value}
|
||||
|
||||
class FakeFormatter(format.Formatter):
|
||||
@ -154,7 +154,7 @@ class TestComponent(base.TestCase):
|
||||
name = "name"
|
||||
expected_value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {}
|
||||
|
||||
instance = Parent()
|
||||
@ -167,7 +167,7 @@ class TestComponent(base.TestCase):
|
||||
def test_set_name_typed(self):
|
||||
expected_value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {}
|
||||
|
||||
instance = Parent()
|
||||
@ -177,7 +177,7 @@ class TestComponent(base.TestCase):
|
||||
# instance that would allow us to call `assert_called_once_with` to
|
||||
# ensure that we're sending the value through the type.
|
||||
# Instead, we use this tiny version of a similar thing.
|
||||
class FakeType(object):
|
||||
class FakeType:
|
||||
calls = []
|
||||
|
||||
def __init__(self, arg):
|
||||
@ -192,7 +192,7 @@ class TestComponent(base.TestCase):
|
||||
def test_set_name_formatter(self):
|
||||
expected_value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {}
|
||||
|
||||
instance = Parent()
|
||||
@ -220,7 +220,7 @@ class TestComponent(base.TestCase):
|
||||
name = "name"
|
||||
expected_value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {name: expected_value}
|
||||
|
||||
instance = Parent()
|
||||
@ -235,7 +235,7 @@ class TestComponent(base.TestCase):
|
||||
name = "name"
|
||||
expected_value = "123"
|
||||
|
||||
class Parent(object):
|
||||
class Parent:
|
||||
_example = {"what": expected_value}
|
||||
|
||||
instance = Parent()
|
||||
|
@ -75,7 +75,7 @@ def get_string_format_keys(fmt_string, old_style=True):
|
||||
use the old style string formatting.
|
||||
"""
|
||||
if old_style:
|
||||
class AccessSaver(object):
|
||||
class AccessSaver:
|
||||
def __init__(self):
|
||||
self.keys = []
|
||||
|
||||
@ -192,7 +192,7 @@ def maximum_supported_microversion(adapter, client_maximum):
|
||||
return discover.version_to_string(result)
|
||||
|
||||
|
||||
class TinyDAG(object):
|
||||
class TinyDAG:
|
||||
"""Tiny DAG
|
||||
|
||||
Bases on the Kahn's algorithm, and enables parallel visiting of the nodes
|
||||
|
@ -71,7 +71,7 @@ def make_names():
|
||||
for imp in sorted(imports):
|
||||
print(imp)
|
||||
print('\n')
|
||||
print("class ServicesMixin(object):\n")
|
||||
print("class ServicesMixin:\n")
|
||||
for service in services:
|
||||
if service:
|
||||
print(" {service}".format(service=service))
|
||||
|
3
tox.ini
3
tox.ini
@ -107,12 +107,13 @@ commands =
|
||||
# The following are ignored on purpose. It's not super worth it to fix them.
|
||||
# However, if you feel strongly about it, patches will be accepted to fix them
|
||||
# if they fix ALL of the occurances of one and only one of them.
|
||||
# H238 New Style Classes are the default in Python3
|
||||
# H306 Is about alphabetical imports - there's a lot to fix.
|
||||
# H4 Are about docstrings and there's just a huge pile of pre-existing issues.
|
||||
# W503 Is supposed to be off by default but in the latest pycodestyle isn't.
|
||||
# Also, both openstacksdk and Donald Knuth disagree with the rule. Line
|
||||
# breaks should occur before the binary operator for readability.
|
||||
ignore = H306,H4,W503
|
||||
ignore = H238,H306,H4,W503
|
||||
show-source = True
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,openstack/_services_mixin.py
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user