Skip to content

Commit d31765c

Browse files
committed
Fix up ruff and black config
1 parent 1860513 commit d31765c

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

capi_janitor/openstack/openstack.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import urllib.parse
55

66
import httpx
7-
87
from easykube import rest
98

109

capi_janitor/openstack/operator.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import random
66
import string
77

8-
import kopf
9-
import yaml
10-
118
import easykube
129
import httpx
10+
import kopf
11+
import yaml
1312

1413
from . import openstack
1514

@@ -47,9 +46,7 @@ async def on_startup(**kwargs):
4746

4847
@kopf.on.cleanup()
4948
async def on_cleanup(**kwargs):
50-
"""
51-
Runs on operator shutdown.
52-
"""
49+
"""Runs on operator shutdown."""
5350
# Make sure that the easykube client is shut down properly
5451
await ekclient.aclose()
5552

@@ -105,7 +102,6 @@ async def secgroups_for_cluster(resource, cluster):
105102

106103
async def filtered_volumes_for_cluster(resource, cluster):
107104
"""Async iterator for volumes belonging to the specified cluster."""
108-
109105
async for vol in resource.list():
110106
# CSI Cinder sets metadata on the volumes that we can look for
111107
owner = vol.metadata.get("cinder.csi.openstack.org/cluster")
@@ -162,7 +158,6 @@ async def purge_openstack_resources(
162158
logger, clouds, cloud_name, cacert, name, include_volumes, include_appcred
163159
):
164160
"""Cleans up the OpenStack resources created by the OCCM and CSI for a cluster."""
165-
166161
# Use the credential to delete external resources as required
167162
async with openstack.Cloud.from_clouds(clouds, cloud_name, cacert) as cloud:
168163
if not cloud.is_authenticated:
@@ -360,7 +355,6 @@ async def _on_openstackcluster_event_impl(
360355
name, namespace, meta, labels, spec, logger, **kwargs
361356
):
362357
"""Executes whenever an event occurs for an OpenStack cluster."""
363-
364358
# Get the resource for manipulating OpenStackClusters at the preferred version
365359
openstackclusters = await _get_os_cluster_client()
366360

@@ -375,7 +369,10 @@ async def _on_openstackcluster_event_impl(
375369
if not meta.get("deletionTimestamp"):
376370
if FINALIZER not in finalizers:
377371
await patch_finalizers(
378-
openstackclusters, name, namespace, finalizers + [FINALIZER]
372+
openstackclusters,
373+
name,
374+
namespace,
375+
[*finalizers, FINALIZER],
379376
)
380377
logger.info("added janitor finalizer to cluster")
381378
return

capi_janitor/tests/openstack/test_operator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import base64
22
import unittest
33
from unittest import mock
4-
import yaml
54

65
import easykube
76
import httpx
7+
import yaml
88

9-
from capi_janitor.openstack import openstack
10-
from capi_janitor.openstack import operator
9+
from capi_janitor.openstack import openstack, operator
1110
from capi_janitor.openstack.operator import OPENSTACK_USER_VOLUMES_RECLAIM_PROPERTY
1211

1312

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,30 @@ select = [
1111
"E",
1212
# Pyflakes
1313
"F",
14+
# flake8-builtins
15+
"A",
16+
# Ruff rules
17+
"RUF",
1418
# flake8-async
1519
"ASYNC",
1620
# pyupgrade
1721
"UP",
22+
# tidy imports
23+
"TID",
24+
# sorted imports
25+
"I",
26+
# check complexity
27+
"C90",
28+
# pep8 naming
29+
"N",
1830
]
1931

2032
[tool.mypy]
2133
follow_imports = "silent"
2234
warn_redundant_casts = true
2335
warn_unused_ignores = true
2436
check_untyped_defs = true
37+
38+
[tool.ruff.lint.mccabe]
39+
# Flag errors (`C901`) whenever the complexity level exceeds 5.
40+
max-complexity = 14

0 commit comments

Comments
 (0)