Skip to content

Commit

Permalink
pre-commit: Migrate from black to ruff format
Browse files Browse the repository at this point in the history
This is mostly a case of adding trailing commas and rewrapping things to
fit on one line.

Change-Id: Iaabb38970e8077c3cfd19041c39e3d40d2d93ffa
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Aug 29, 2024
1 parent f83b657 commit 187e88a
Show file tree
Hide file tree
Showing 69 changed files with 161 additions and 431 deletions.
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ repos:
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: ['-S', '-l', '79']
- id: ruff-format
- repo: https://opendev.org/openstack/hacking
rev: 7.0.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion openstack/_hacking/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def assert_no_deprecated_exceptions(logical_line, filename):
'OpenStackCloudURINotFound',
'OpenStackCloudResourceNotFound',
):
if re.search(fr'\b{exception}\b', logical_line):
if re.search(rf'\b{exception}\b', logical_line):
yield (0, 'O310: Use of deprecated Exception class')
2 changes: 1 addition & 1 deletion openstack/accelerator/v2/deployable.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _commit(
json=request.body,
headers=request.headers,
microversion=microversion,
**kwargs
**kwargs,
)
self.microversion = microversion
self._translate_response(response, has_body=has_body)
Expand Down
1 change: 0 additions & 1 deletion openstack/cloud/_accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class AcceleratorCloudMixin(openstackcloud._OpenStackCloudMixin):

def list_deployables(self, filters=None):
"""List all available deployables.
Expand Down
33 changes: 12 additions & 21 deletions openstack/cloud/_baremetal.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def _normalize_port_list(nics):


class BaremetalCloudMixin(openstackcloud._OpenStackCloudMixin):

def list_nics(self):
"""Return a list of all bare metal ports."""
return list(self.baremetal.ports(details=True))
Expand Down Expand Up @@ -187,7 +186,7 @@ def register_machine(
timeout=3600,
lock_timeout=600,
provision_state='available',
**kwargs
**kwargs,
):
"""Register Baremetal with Ironic
Expand All @@ -208,10 +207,7 @@ def register_machine(
Example::
[
{'address': 'aa:bb:cc:dd:ee:01'},
{'address': 'aa:bb:cc:dd:ee:02'}
]
[{'address': 'aa:bb:cc:dd:ee:01'}, {'address': 'aa:bb:cc:dd:ee:02'}]
Alternatively, you can provide an array of MAC addresses.
:param wait: Boolean value, defaulting to false, to wait for the node
Expand Down Expand Up @@ -352,21 +348,16 @@ def patch_machine(self, name_or_id, patch):
Example patch construction::
patch=[]
patch.append({
'op': 'remove',
'path': '/instance_info'
})
patch.append({
'op': 'replace',
'path': '/name',
'value': 'newname'
})
patch.append({
'op': 'add',
'path': '/driver_info/username',
'value': 'administrator'
})
patch = []
patch.append({'op': 'remove', 'path': '/instance_info'})
patch.append({'op': 'replace', 'path': '/name', 'value': 'newname'})
patch.append(
{
'op': 'add',
'path': '/driver_info/username',
'value': 'administrator',
}
)
:returns: Current state of the node.
:rtype: :class:`~openstack.baremetal.v1.node.Node`.
Expand Down
61 changes: 10 additions & 51 deletions openstack/cloud/_block_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):

# TODO(stephenfin): Remove 'cache' in a future major version
def list_volumes(self, cache=True):
"""List all available volumes.
Expand Down Expand Up @@ -59,12 +58,7 @@ def get_volume(self, name_or_id, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand Down Expand Up @@ -94,12 +88,7 @@ def get_volume_type(self, name_or_id, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand Down Expand Up @@ -467,12 +456,7 @@ def get_volume_snapshot(self, name_or_id, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand Down Expand Up @@ -542,12 +526,7 @@ def get_volume_backup(self, name_or_id, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand All @@ -570,7 +549,7 @@ def list_volume_snapshots(self, detailed=True, filters=None):
{
'name': 'my-volume-snapshot',
'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56',
'all_tenants': 1
'all_tenants': 1,
}
:returns: A list of volume ``Snapshot`` objects.
Expand All @@ -590,7 +569,7 @@ def list_volume_backups(self, detailed=True, filters=None):
'name': 'my-volume-backup',
'status': 'available',
'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56',
'all_tenants': 1
'all_tenants': 1,
}
:returns: A list of volume ``Backup`` objects.
Expand Down Expand Up @@ -671,12 +650,7 @@ def search_volumes(self, name_or_id=None, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand All @@ -698,12 +672,7 @@ def search_volume_snapshots(self, name_or_id=None, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand All @@ -725,12 +694,7 @@ def search_volume_backups(self, name_or_id=None, filters=None):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand Down Expand Up @@ -758,12 +722,7 @@ def search_volume_types(
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
Expand Down
15 changes: 2 additions & 13 deletions openstack/cloud/_coe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class CoeCloudMixin(openstackcloud._OpenStackCloudMixin):

def list_coe_clusters(self):
"""List COE (Container Orchestration Engine) cluster.
Expand Down Expand Up @@ -51,12 +50,7 @@ def get_coe_cluster(self, name_or_id, filters=None):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
Expand Down Expand Up @@ -207,12 +201,7 @@ def get_cluster_template(self, name_or_id, filters=None, detail=False):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
Expand Down
26 changes: 4 additions & 22 deletions openstack/cloud/_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def _pop_or_get(resource, key, default, strict):


class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):

@property
def _compute_region(self):
# This is only used in exception messages. Can we get rid of it?
Expand Down Expand Up @@ -398,12 +397,7 @@ def get_keypair(self, name_or_id, filters=None):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
Expand All @@ -421,12 +415,7 @@ def get_flavor(self, name_or_id, filters=None, get_extra=True):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
Expand Down Expand Up @@ -505,12 +494,7 @@ def get_server(
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
Expand Down Expand Up @@ -1640,9 +1624,7 @@ def get_aggregate(self, name_or_id, filters=None):
{
'availability_zone': 'nova',
'metadata': {
'cpu_allocation_ratio': '1.0'
}
'metadata': {'cpu_allocation_ratio': '1.0'},
}
:returns: An aggregate dict or None if no matching aggregate is
Expand Down
1 change: 0 additions & 1 deletion openstack/cloud/_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class DnsCloudMixin(openstackcloud._OpenStackCloudMixin):

def list_zones(self, filters=None):
"""List all available zones.
Expand Down
Loading

0 comments on commit 187e88a

Please sign in to comment.