Skip to content

Commit c2be1f1

Browse files
committed
chore : ruff failure fix (#43)
1 parent 285185d commit c2be1f1

File tree

9 files changed

+149
-67
lines changed

9 files changed

+149
-67
lines changed

src/openstack_mcp_server/tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ def register_tool(mcp: FastMCP):
66
Register Openstack MCP tools.
77
"""
88

9+
from .block_storage_tools import BlockStorageTools
910
from .compute_tools import ComputeTools
1011
from .identity_tools import IdentityTools
1112
from .image_tools import ImageTools
1213
from .network_tools import NetworkTools
13-
from .block_storage_tools import BlockStorageTools
1414

1515
ComputeTools().register_tools(mcp)
1616
ImageTools().register_tools(mcp)

src/openstack_mcp_server/tools/block_storage_tools.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from fastmcp import FastMCP
2+
3+
from .base import get_openstack_conn
14
from .response.block_storage import (
25
Volume,
36
VolumeAttachment,
47
)
5-
from .base import get_openstack_conn
6-
from fastmcp import FastMCP
78

89

910
class BlockStorageTools:
@@ -39,7 +40,7 @@ def get_volumes(self) -> list[Volume]:
3940
server_id=attachment.get("server_id"),
4041
device=attachment.get("device"),
4142
attachment_id=attachment.get("id"),
42-
)
43+
),
4344
)
4445

4546
volume_list.append(
@@ -57,7 +58,7 @@ def get_volumes(self) -> list[Volume]:
5758
is_encrypted=volume.is_encrypted,
5859
description=volume.description,
5960
attachments=attachments,
60-
)
61+
),
6162
)
6263

6364
return volume_list
@@ -80,7 +81,7 @@ def get_volume_details(self, volume_id: str) -> Volume:
8081
server_id=attachment.get("server_id"),
8182
device=attachment.get("device"),
8283
attachment_id=attachment.get("id"),
83-
)
84+
),
8485
)
8586

8687
return Volume(
@@ -133,7 +134,10 @@ def create_volume(
133134
volume_kwargs["availability_zone"] = availability_zone
134135

135136
volume = conn.block_storage.create_volume(
136-
size=size, image=image, bootable=bootable, **volume_kwargs
137+
size=size,
138+
image=image,
139+
bootable=bootable,
140+
**volume_kwargs,
137141
)
138142

139143
volume_obj = Volume(
@@ -162,7 +166,11 @@ def delete_volume(self, volume_id: str, force: bool = False) -> None:
162166
"""
163167
conn = get_openstack_conn()
164168

165-
conn.block_storage.delete_volume(volume_id, force=force, ignore_missing=False)
169+
conn.block_storage.delete_volume(
170+
volume_id,
171+
force=force,
172+
ignore_missing=False,
173+
)
166174

167175
def extend_volume(self, volume_id: str, new_size: int) -> None:
168176
"""
@@ -174,4 +182,4 @@ def extend_volume(self, volume_id: str, new_size: int) -> None:
174182
"""
175183
conn = get_openstack_conn()
176184

177-
conn.block_storage.extend_volume(volume_id, new_size)
185+
conn.block_storage.extend_volume(volume_id, new_size)

src/openstack_mcp_server/tools/identity_tools.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from fastmcp import FastMCP
22

33
from .base import get_openstack_conn
4-
from .response.identity import Region, Domain
4+
from .response.identity import Domain, Region
55

66

77
class IdentityTools:
@@ -19,7 +19,7 @@ def register_tools(self, mcp: FastMCP):
1919
mcp.tool()(self.create_region)
2020
mcp.tool()(self.delete_region)
2121
mcp.tool()(self.update_region)
22-
22+
2323
mcp.tool()(self.get_domains)
2424
mcp.tool()(self.get_domain)
2525

@@ -103,7 +103,7 @@ def update_region(self, id: str, description: str = "") -> Region:
103103
id=updated_region.id,
104104
description=updated_region.description,
105105
)
106-
106+
107107
def get_domains(self) -> list[Domain]:
108108
"""
109109
Get the list of Identity domains.
@@ -115,7 +115,12 @@ def get_domains(self) -> list[Domain]:
115115
domain_list = []
116116
for domain in conn.identity.domains():
117117
domain_list.append(
118-
Domain(id=domain.id, name=domain.name, description=domain.description, is_enabled=domain.is_enabled),
118+
Domain(
119+
id=domain.id,
120+
name=domain.name,
121+
description=domain.description,
122+
is_enabled=domain.is_enabled,
123+
),
119124
)
120125
return domain_list
121126

@@ -128,8 +133,12 @@ def get_domain(self, id: str) -> Domain:
128133
:return: The Domain object.
129134
"""
130135
conn = get_openstack_conn()
131-
136+
132137
domain = conn.identity.get_domain(domain=id)
133138

134-
return Domain(id=domain.id, name=domain.name, description=domain.description, is_enabled=domain.is_enabled)
135-
139+
return Domain(
140+
id=domain.id,
141+
name=domain.name,
142+
description=domain.description,
143+
is_enabled=domain.is_enabled,
144+
)

src/openstack_mcp_server/tools/response/block_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ class Volume(BaseModel):
1818
is_bootable: bool | None = None
1919
is_encrypted: bool | None = None
2020
description: str | None = None
21-
attachments: list[VolumeAttachment] = []
21+
attachments: list[VolumeAttachment] = []

src/openstack_mcp_server/tools/response/identity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Region(BaseModel):
77
id: str
88
description: str = ""
99

10+
1011
class Domain(BaseModel):
1112
id: str
1213
name: str

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def mock_openstack_connect_network():
6262
):
6363
yield mock_conn
6464

65+
6566
@pytest.fixture
6667
def mock_get_openstack_conn_block_storage():
6768
"""Mock get_openstack_conn function for block_storage_tools."""

0 commit comments

Comments
 (0)