Skip to content

Commit 8947891

Browse files
linting
1 parent f985f36 commit 8947891

3 files changed

Lines changed: 15 additions & 19 deletions

File tree

cleancloud/providers/gcp/rules/ai/workbench_idle.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@
5555
# Exact documented resource-name pattern (spec 3.1, 7):
5656
# projects/{projectId}/locations/{location}/instances/{instanceId}
5757
# All four non-empty path segments must be present.
58-
_INSTANCE_NAME_RE = re.compile(
59-
r"^projects/[^/]+/locations/[^/]+/instances/[^/]+$"
60-
)
58+
_INSTANCE_NAME_RE = re.compile(r"^projects/[^/]+/locations/[^/]+/instances/[^/]+$")
6159

6260

6361
def find_idle_workbench_instances(
@@ -117,10 +115,7 @@ def _list_instances(
117115
results: list = []
118116
unreachable: list = []
119117
discovery_failed = False
120-
url = (
121-
f"https://notebooks.googleapis.com/v2"
122-
f"/projects/{project_id}/locations/-/instances"
123-
)
118+
url = f"https://notebooks.googleapis.com/v2" f"/projects/{project_id}/locations/-/instances"
124119
params: dict = {"pageSize": 100}
125120

126121
while True:

tests/cleancloud/providers/azure/test_azure_app_service_idle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def _failing_iter(*args, **kwargs):
792792
# Yield nothing, then raise — simulates a pager that fails before
793793
# returning any results (first page network error, etc.)
794794
raise Exception("pager failed mid-iteration")
795-
yield # noqa: unreachable — makes this a generator
795+
yield # makes this a generator
796796

797797
web.web_apps.list_web_jobs.side_effect = _failing_iter
798798
findings = find_idle_app_services(

tests/cleancloud/providers/gcp/ai/test_gcp_workbench_idle.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def _invoke(**kwargs):
8080
"cleancloud.providers.gcp.rules.ai.workbench_idle.AuthorizedSession",
8181
return_value=_session(_ok()),
8282
):
83-
return find_idle_workbench_instances(
84-
project_id=_PROJECT, credentials=MagicMock(), **kwargs
85-
)
83+
return find_idle_workbench_instances(project_id=_PROJECT, credentials=MagicMock(), **kwargs)
8684

8785

8886
def _invoke_with_session(mock_session, **kwargs):
@@ -91,9 +89,7 @@ def _invoke_with_session(mock_session, **kwargs):
9189
"cleancloud.providers.gcp.rules.ai.workbench_idle.AuthorizedSession",
9290
return_value=mock_session,
9391
):
94-
return find_idle_workbench_instances(
95-
project_id=_PROJECT, credentials=MagicMock(), **kwargs
96-
)
92+
return find_idle_workbench_instances(project_id=_PROJECT, credentials=MagicMock(), **kwargs)
9793

9894

9995
# ---------------------------------------------------------------------------
@@ -110,13 +106,19 @@ def test_always_empty(self):
110106

111107
def test_empty_when_api_returns_active_instances(self):
112108
"""EMITTING_DISABLED: ACTIVE instances in API response still yield no findings."""
113-
inst = {"name": f"projects/{_PROJECT}/locations/us-central1/instances/wb-1", "state": "ACTIVE"}
109+
inst = {
110+
"name": f"projects/{_PROJECT}/locations/us-central1/instances/wb-1",
111+
"state": "ACTIVE",
112+
}
114113
result = _invoke_with_session(_session(_ok({"instances": [inst]})))
115114
assert result == []
116115

117116
def test_empty_when_api_returns_multiple_instances(self):
118117
instances = [
119-
{"name": f"projects/{_PROJECT}/locations/us-central1/instances/wb-{i}", "state": "ACTIVE"}
118+
{
119+
"name": f"projects/{_PROJECT}/locations/us-central1/instances/wb-{i}",
120+
"state": "ACTIVE",
121+
}
120122
for i in range(5)
121123
]
122124
result = _invoke_with_session(_session(_ok({"instances": instances})))
@@ -131,9 +133,7 @@ def test_empty_when_api_returns_multiple_instances(self):
131133
class TestIdleDaysValidation:
132134
def test_zero_raises_value_error(self):
133135
with pytest.raises(ValueError, match="idle_days must be >= 1"):
134-
find_idle_workbench_instances(
135-
project_id=_PROJECT, credentials=MagicMock(), idle_days=0
136-
)
136+
find_idle_workbench_instances(project_id=_PROJECT, credentials=MagicMock(), idle_days=0)
137137

138138
def test_negative_one_raises(self):
139139
with pytest.raises(ValueError, match="idle_days must be >= 1"):
@@ -352,6 +352,7 @@ def test_two_pages_accumulates_instances(self):
352352
def test_three_pages_all_accumulated(self):
353353
def _inst(i):
354354
return {"name": f"projects/p/locations/us-central1/instances/i{i}", "state": "ACTIVE"}
355+
355356
session = _session(
356357
_ok({"instances": [_inst(1)], "nextPageToken": "t1"}),
357358
_ok({"instances": [_inst(2)], "nextPageToken": "t2"}),

0 commit comments

Comments
 (0)