Skip to content

Commit cda953c

Browse files
authored
[Key Vault] Resolve failures on pylint 3.0.3 (#35551)
1 parent dc73ceb commit cda953c

File tree

4 files changed

+68
-30
lines changed

4 files changed

+68
-30
lines changed

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# Copyright (c) Microsoft Corporation.
33
# Licensed under the MIT License.
44
# ------------------------------------
5-
from typing import Any, Union
5+
from typing import Any, List, Optional, Union
66
from uuid import UUID, uuid4
77

88
from azure.core.exceptions import ResourceNotFoundError
99
from azure.core.paging import ItemPaged
1010
from azure.core.tracing.decorator import distributed_trace
1111

1212
from ._enums import KeyVaultRoleScope
13-
from ._models import KeyVaultRoleAssignment, KeyVaultRoleDefinition
13+
from ._models import KeyVaultPermission, KeyVaultRoleAssignment, KeyVaultRoleDefinition
1414
from ._internal import KeyVaultClientBase
1515

1616

@@ -34,7 +34,13 @@ class KeyVaultAccessControlClient(KeyVaultClientBase):
3434

3535
@distributed_trace
3636
def create_role_assignment(
37-
self, scope: Union[str, KeyVaultRoleScope], definition_id: str, principal_id: str, **kwargs: Any
37+
self,
38+
scope: Union[str, KeyVaultRoleScope],
39+
definition_id: str,
40+
principal_id: str,
41+
*,
42+
name: Optional[Union[str, UUID]] = None,
43+
**kwargs: Any,
3844
) -> KeyVaultRoleAssignment:
3945
"""Create a role assignment.
4046
@@ -51,7 +57,7 @@ def create_role_assignment(
5157
:returns: The created role assignment.
5258
:rtype: ~azure.keyvault.administration.KeyVaultRoleAssignment
5359
"""
54-
name = kwargs.pop("name", None) or uuid4()
60+
assignment_name = name or uuid4()
5561

5662
create_parameters = self._client.role_assignments.models.RoleAssignmentCreateParameters(
5763
properties=self._client.role_assignments.models.RoleAssignmentProperties(
@@ -61,7 +67,7 @@ def create_role_assignment(
6167
assignment = self._client.role_assignments.create(
6268
vault_base_url=self._vault_url,
6369
scope=scope,
64-
role_assignment_name=str(name),
70+
role_assignment_name=str(assignment_name),
6571
parameters=create_parameters,
6672
**kwargs
6773
)
@@ -131,7 +137,15 @@ def list_role_assignments(
131137

132138
@distributed_trace
133139
def set_role_definition(
134-
self, scope: Union[str, KeyVaultRoleScope], **kwargs: Any
140+
self,
141+
scope: Union[str, KeyVaultRoleScope],
142+
*,
143+
name: Optional[Union[str, UUID]] = None,
144+
role_name: Optional[str] = None,
145+
description: Optional[str] = None,
146+
permissions: Optional[List[KeyVaultPermission]] = None,
147+
assignable_scopes: Optional[Union[List[str], List[KeyVaultRoleScope]]] = None,
148+
**kwargs: Any,
135149
) -> KeyVaultRoleDefinition:
136150
"""Creates or updates a custom role definition.
137151
@@ -160,28 +174,28 @@ def set_role_definition(
160174
:returns: The created or updated role definition
161175
:rtype: ~azure.keyvault.administration.KeyVaultRoleDefinition
162176
"""
163-
permissions = [
177+
role_permissions = [
164178
self._client.role_definitions.models.Permission(
165179
actions=p.actions,
166180
not_actions=p.not_actions,
167181
data_actions=p.data_actions,
168182
not_data_actions=p.not_data_actions,
169183
)
170-
for p in kwargs.pop("permissions", None) or []
184+
for p in permissions or []
171185
]
172186

173187
properties = self._client.role_definitions.models.RoleDefinitionProperties(
174-
role_name=kwargs.pop("role_name", None),
175-
description=kwargs.pop("description", None),
176-
permissions=permissions,
177-
assignable_scopes=kwargs.pop("assignable_scopes", None),
188+
role_name=role_name,
189+
description=description,
190+
permissions=role_permissions,
191+
assignable_scopes=assignable_scopes,
178192
)
179193
parameters = self._client.role_definitions.models.RoleDefinitionCreateParameters(properties=properties)
180194

181195
definition = self._client.role_definitions.create_or_update(
182196
vault_base_url=self._vault_url,
183197
scope=scope,
184-
role_definition_name=str(kwargs.pop("name", None) or uuid4()),
198+
role_definition_name=str(name or uuid4()),
185199
parameters=parameters,
186200
**kwargs
187201
)

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ def begin_backup(
6262
) -> LROPoller[KeyVaultBackupResult]:
6363
...
6464

65+
# Disabling pylint checks because they don't correctly handle overloads
6566
@distributed_trace
66-
def begin_backup(self, blob_storage_url: str, *args: str, **kwargs: Any) -> LROPoller[KeyVaultBackupResult]:
67+
def begin_backup( # pylint: disable=docstring-missing-param,docstring-keyword-should-match-keyword-only
68+
self, blob_storage_url: str, *args: str, **kwargs: Any
69+
) -> LROPoller[KeyVaultBackupResult]:
6770
"""Begin a full backup of the Key Vault.
6871
6972
:param str blob_storage_url: URL of the blob storage container in which the backup will be stored, for example
@@ -154,8 +157,11 @@ def begin_restore(
154157
) -> LROPoller[None]:
155158
...
156159

160+
# Disabling pylint checks because they don't correctly handle overloads
157161
@distributed_trace
158-
def begin_restore(self, folder_url: str, *args: str, **kwargs: Any) -> LROPoller[None]:
162+
def begin_restore( # pylint: disable=docstring-missing-param,docstring-keyword-should-match-keyword-only
163+
self, folder_url: str, *args: str, **kwargs: Any
164+
) -> LROPoller[None]:
159165
"""Restore a Key Vault backup.
160166
161167
This method restores either a complete Key Vault backup or when ``key_name`` has a value, a single key.

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_access_control_client.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (c) Microsoft Corporation.
33
# Licensed under the MIT License.
44
# ------------------------------------
5-
from typing import Any, Union
5+
from typing import Any, List, Optional, Union
66
from uuid import UUID, uuid4
77

88
from azure.core.async_paging import AsyncItemPaged
@@ -11,7 +11,7 @@
1111
from azure.core.tracing.decorator_async import distributed_trace_async
1212

1313
from .._enums import KeyVaultRoleScope
14-
from .._models import KeyVaultRoleAssignment, KeyVaultRoleDefinition
14+
from .._models import KeyVaultPermission, KeyVaultRoleAssignment, KeyVaultRoleDefinition
1515
from .._internal import AsyncKeyVaultClientBase
1616

1717

@@ -35,7 +35,13 @@ class KeyVaultAccessControlClient(AsyncKeyVaultClientBase):
3535

3636
@distributed_trace_async
3737
async def create_role_assignment(
38-
self, scope: Union[str, KeyVaultRoleScope], definition_id: str, principal_id: str, **kwargs: Any
38+
self,
39+
scope: Union[str, KeyVaultRoleScope],
40+
definition_id: str,
41+
principal_id: str,
42+
*,
43+
name: Optional[Union[str, UUID]] = None,
44+
**kwargs: Any,
3945
) -> KeyVaultRoleAssignment:
4046
"""Create a role assignment.
4147
@@ -52,7 +58,7 @@ async def create_role_assignment(
5258
:returns: The created role assignment.
5359
:rtype: ~azure.keyvault.administration.KeyVaultRoleAssignment
5460
"""
55-
name = kwargs.pop("name", None) or uuid4()
61+
assignment_name = name or uuid4()
5662

5763
create_parameters = self._client.role_assignments.models.RoleAssignmentCreateParameters(
5864
properties=self._client.role_assignments.models.RoleAssignmentProperties(
@@ -62,7 +68,7 @@ async def create_role_assignment(
6268
assignment = await self._client.role_assignments.create(
6369
vault_base_url=self._vault_url,
6470
scope=scope,
65-
role_assignment_name=str(name),
71+
role_assignment_name=str(assignment_name),
6672
parameters=create_parameters,
6773
**kwargs
6874
)
@@ -132,7 +138,15 @@ def list_role_assignments(
132138

133139
@distributed_trace_async
134140
async def set_role_definition(
135-
self, scope: Union[str, KeyVaultRoleScope], **kwargs: Any
141+
self,
142+
scope: Union[str, KeyVaultRoleScope],
143+
*,
144+
name: Optional[Union[str, UUID]] = None,
145+
role_name: Optional[str] = None,
146+
description: Optional[str] = None,
147+
permissions: Optional[List[KeyVaultPermission]] = None,
148+
assignable_scopes: Optional[Union[List[str], List[KeyVaultRoleScope]]] = None,
149+
**kwargs: Any,
136150
) -> KeyVaultRoleDefinition:
137151
"""Creates or updates a custom role definition.
138152
@@ -161,28 +175,28 @@ async def set_role_definition(
161175
:returns: The created or updated role definition
162176
:rtype: ~azure.keyvault.administration.KeyVaultRoleDefinition
163177
"""
164-
permissions = [
178+
role_permissions = [
165179
self._client.role_definitions.models.Permission(
166180
actions=p.actions,
167181
not_actions=p.not_actions,
168182
data_actions=p.data_actions,
169183
not_data_actions=p.not_data_actions,
170184
)
171-
for p in kwargs.pop("permissions", None) or []
185+
for p in permissions or []
172186
]
173187

174188
properties = self._client.role_definitions.models.RoleDefinitionProperties(
175-
role_name=kwargs.pop("role_name", None),
176-
description=kwargs.pop("description", None),
177-
permissions=permissions,
178-
assignable_scopes=kwargs.pop("assignable_scopes", None),
189+
role_name=role_name,
190+
description=description,
191+
permissions=role_permissions,
192+
assignable_scopes=assignable_scopes,
179193
)
180194
parameters = self._client.role_definitions.models.RoleDefinitionCreateParameters(properties=properties)
181195

182196
definition = await self._client.role_definitions.create_or_update(
183197
vault_base_url=self._vault_url,
184198
scope=scope,
185-
role_definition_name=str(kwargs.pop("name", None) or uuid4()),
199+
role_definition_name=str(name or uuid4()),
186200
parameters=parameters,
187201
**kwargs
188202
)

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_backup_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ async def begin_backup(
5757
) -> AsyncLROPoller[KeyVaultBackupResult]:
5858
...
5959

60+
# Disabling pylint checks because they don't correctly handle overloads
6061
@distributed_trace_async
61-
async def begin_backup(
62+
async def begin_backup( # pylint: disable=docstring-missing-param,docstring-keyword-should-match-keyword-only
6263
self, blob_storage_url: str, *args: str, **kwargs: Any
6364
) -> AsyncLROPoller[KeyVaultBackupResult]:
6465
"""Begin a full backup of the Key Vault.
@@ -150,8 +151,11 @@ async def begin_restore(
150151
) -> AsyncLROPoller[None]:
151152
...
152153

154+
# Disabling pylint checks because they don't correctly handle overloads
153155
@distributed_trace_async
154-
async def begin_restore(self, folder_url: str, *args: str, **kwargs: Any) -> AsyncLROPoller[None]:
156+
async def begin_restore( # pylint: disable=docstring-missing-param,docstring-keyword-should-match-keyword-only
157+
self, folder_url: str, *args: str, **kwargs: Any
158+
) -> AsyncLROPoller[None]:
155159
"""Restore a Key Vault backup.
156160
157161
This method restores either a complete Key Vault backup or when ``key_name`` has a value, a single key.

0 commit comments

Comments
 (0)