Skip to content

Commit 438c078

Browse files
committed
fix(identity): Remove docstring required, optional keywords(#31)
1 parent b593684 commit 438c078

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/openstack_mcp_server/tools/identity_tools.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_region(self, id: str) -> Region:
4646
"""
4747
Get a region.
4848
49-
:param id: The ID of the region. (required)
49+
:param id: The ID of the region.
5050
5151
:return: The Region object.
5252
"""
@@ -56,12 +56,12 @@ def get_region(self, id: str) -> Region:
5656

5757
return Region(id=region.id, description=region.description)
5858

59-
def create_region(self, id: str, description: str = "") -> Region:
59+
def create_region(self, id: str, description: str | None= None) -> Region:
6060
"""
6161
Create a new region.
6262
63-
:param id: The ID of the region. (required)
64-
:param description: The description of the region. (optional)
63+
:param id: The ID of the region.
64+
:param description: The description of the region.
6565
6666
:return: The created Region object.
6767
"""
@@ -75,7 +75,7 @@ def delete_region(self, id: str) -> None:
7575
"""
7676
Delete a region.
7777
78-
:param id: The ID of the region. (required)
78+
:param id: The ID of the region.
7979
8080
:return: None
8181
"""
@@ -86,12 +86,12 @@ def delete_region(self, id: str) -> None:
8686

8787
return None
8888

89-
def update_region(self, id: str, description: str = "") -> Region:
89+
def update_region(self, id: str, description: str | None = None) -> Region:
9090
"""
9191
Update a region.
9292
93-
:param id: The ID of the region. (required)
94-
:param description: The string description of the region. (optional)
93+
:param id: The ID of the region.
94+
:param description: The string description of the region.
9595
9696
:return: The updated Region object.
9797
"""
@@ -131,7 +131,7 @@ def get_domain(self, name: str) -> Domain:
131131
"""
132132
Get a domain.
133133
134-
:param name: The name of the domain. (required)
134+
:param name: The name of the domain.
135135
136136
:return: The Domain object.
137137
"""
@@ -149,15 +149,15 @@ def get_domain(self, name: str) -> Domain:
149149
def create_domain(
150150
self,
151151
name: str,
152-
description: str = "",
153-
is_enabled: bool = False,
152+
description: str | None = None,
153+
is_enabled: bool | None = False,
154154
) -> Domain:
155155
"""
156156
Create a new domain.
157157
158-
:param name: The name of the domain. (required)
159-
:param description: The description of the domain. (optional)
160-
:param is_enabled: Whether the domain is enabled. (optional)
158+
:param name: The name of the domain.
159+
:param description: The description of the domain.
160+
:param is_enabled: Whether the domain is enabled.
161161
"""
162162
conn = get_openstack_conn()
163163

@@ -178,7 +178,7 @@ def delete_domain(self, name: str) -> None:
178178
"""
179179
Delete a domain.
180180
181-
:param name: The name of the domain. (required)
181+
:param name: The name of the domain.
182182
"""
183183
conn = get_openstack_conn()
184184

@@ -197,10 +197,10 @@ def update_domain(
197197
"""
198198
Update a domain.
199199
200-
:param id: The ID of the domain. (required)
201-
:param name: The name of the domain. (optional)
202-
:param description: The description of the domain. (optional)
203-
:param is_enabled: Whether the domain is enabled. (optional)
200+
:param id: The ID of the domain.
201+
:param name: The name of the domain.
202+
:param description: The description of the domain.
203+
:param is_enabled: Whether the domain is enabled.
204204
"""
205205
conn = get_openstack_conn()
206206

src/openstack_mcp_server/tools/response/identity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# In this case, we are only using description field as optional.
66
class Region(BaseModel):
77
id: str
8-
description: str = ""
8+
description: str | None = None
99

1010

1111
class Domain(BaseModel):
1212
id: str
1313
name: str
14-
description: str = ""
15-
is_enabled: bool = False
14+
description: str | None = None
15+
is_enabled: bool | None = None

tests/tools/test_identity_tools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_create_region_without_description(
103103
# Create mock region object
104104
mock_region = Mock()
105105
mock_region.id = "RegionOne"
106-
mock_region.description = ""
106+
mock_region.description = None
107107

108108
# Configure mock region.create_region()
109109
mock_conn.identity.create_region.return_value = mock_region
@@ -233,7 +233,7 @@ def test_update_region_without_description(
233233
# Create mock region object
234234
mock_region = Mock()
235235
mock_region.id = "RegionOne"
236-
mock_region.description = ""
236+
mock_region.description = None
237237

238238
# Configure mock region.update_region()
239239
mock_conn.identity.update_region.return_value = mock_region
@@ -248,7 +248,7 @@ def test_update_region_without_description(
248248
# Verify mock calls
249249
mock_conn.identity.update_region.assert_called_once_with(
250250
region="RegionOne",
251-
description="",
251+
description=None,
252252
)
253253

254254
def test_update_region_invalid_id_format(
@@ -519,7 +519,7 @@ def test_create_domain_without_description(
519519
mock_domain = Mock()
520520
mock_domain.id = "d01a81393377480cbd75c0210442e687"
521521
mock_domain.name = "domainone"
522-
mock_domain.description = ""
522+
mock_domain.description = None
523523
mock_domain.is_enabled = False
524524

525525
# Configure mock domain.create_domain()
@@ -533,14 +533,14 @@ def test_create_domain_without_description(
533533
assert result == Domain(
534534
id="d01a81393377480cbd75c0210442e687",
535535
name="domainone",
536-
description="",
536+
description=None,
537537
is_enabled=False,
538538
)
539539

540540
# Verify mock calls
541541
mock_conn.identity.create_domain.assert_called_once_with(
542542
name="domainone",
543-
description="",
543+
description=None,
544544
enabled=False,
545545
)
546546

0 commit comments

Comments
 (0)