Skip to content

Commit 2e740fe

Browse files
author
Nicola Camillucci
committed
MyPy, PyLint, Snippets
1 parent 8e50c45 commit 2e740fe

4 files changed

Lines changed: 17 additions & 16 deletions

File tree

sdk/keyvault/azure-keyvault-administration/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ role_definition = client.set_role_definition(scope=scope, role_name=role_name, p
193193
```python
194194
new_permissions = [
195195
KeyVaultPermission(
196-
data_actions=[KeyVaultDataAction.READ_HSM_KEY],
197-
not_data_actions=[KeyVaultDataAction.CREATE_HSM_KEY]
196+
data_actions=[KeyVaultDataAction.READ_HSM_KEY], not_data_actions=[KeyVaultDataAction.CREATE_HSM_KEY]
198197
)
199198
]
200199
unique_definition_name = role_definition.name

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,9 @@ def create_oct_key(
399399
)
400400

401401
@distributed_trace
402-
def begin_delete_key(
402+
def begin_delete_key( # pylint:disable=bad-option-value,delete-operation-wrong-return-type
403403
self, name: str, **kwargs: Any
404-
) -> LROPoller[DeletedKey]: # pylint:disable=bad-option-value,delete-operation-wrong-return-type
404+
) -> LROPoller[DeletedKey]:
405405
"""Delete all versions of a key and its cryptographic material.
406406
407407
Requires keys/delete permission. When this method returns Key Vault has begun deleting the key. Deletion may

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_models.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ def recovery_level(self) -> Optional[str]:
253253
return self._attributes.recovery_level if self._attributes else None
254254

255255
@property
256-
def tags(self) -> Dict[str, str]:
256+
def tags(self) -> Optional[Dict[str, str]]:
257257
"""Application specific metadata in the form of key-value pairs.
258258
259259
:returns: A dictionary of tags attached to the key.
260-
:rtype: dict[str, str]
260+
:rtype: dict[str, str] or None
261261
"""
262262
return self._tags
263263

@@ -313,9 +313,8 @@ def attestation(self) -> Optional[KeyAttestation]:
313313
# attestation was added in 7.6-preview.2
314314
if self._attributes:
315315
attestation = getattr(self._attributes, "attestation", None)
316-
return (
317-
KeyAttestation._from_generated(attestation=attestation) if attestation else None
318-
) # pylint:disable=protected-access
316+
if attestation:
317+
return KeyAttestation._from_generated(attestation=attestation) # pylint:disable=protected-access
319318
return None
320319

321320

@@ -414,8 +413,8 @@ def _from_generated(cls, policy: "_models.KeyRotationPolicy") -> "KeyRotationPol
414413
[]
415414
if policy.lifetime_actions is None
416415
else [
417-
KeyRotationLifetimeAction._from_generated(action)
418-
for action in policy.lifetime_actions # pylint:disable=protected-access
416+
KeyRotationLifetimeAction._from_generated(action) # pylint:disable=protected-access
417+
for action in policy.lifetime_actions
419418
]
420419
)
421420
if policy.attributes:

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_models.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ def verify(
240240
if not result.is_valid:
241241
raise InvalidSignature(f"The provided signature '{signature!r}' is invalid.")
242242

243-
def recover_data_from_signature(
244-
self, signature: bytes, padding: AsymmetricPadding, algorithm: Optional[HashAlgorithm]
243+
def recover_data_from_signature( # type: ignore[override] # Parameter subset
244+
self,
245+
signature: bytes,
246+
padding: AsymmetricPadding,
247+
algorithm: Optional[HashAlgorithm],
245248
) -> bytes:
246249
# pylint: disable=line-too-long
247250
"""Recovers the signed data from the signature. Only supported with `cryptography` version 3.3 and above.
@@ -392,7 +395,7 @@ def public_key(self) -> KeyVaultRSAPublicKey:
392395
"""
393396
return KeyVaultRSAPublicKey(self._client, self._key)
394397

395-
def sign(
398+
def sign( # type: ignore[override] # Parameter subset
396399
self,
397400
data: bytes,
398401
padding: AsymmetricPadding,
@@ -413,8 +416,8 @@ def sign(
413416
:returns: The signature, as bytes.
414417
:rtype: bytes
415418
"""
416-
if isinstance(algorithm, Prehashed):
417-
raise ValueError("`Prehashed` algorithms are unsupported. Please provide a `HashAlgorithm` instead.")
419+
if not isinstance(algorithm, HashAlgorithm):
420+
raise ValueError("Only `HashAlgorithm`s are supported. Please provide a `HashAlgorithm` instead.")
418421
mapped_algorithm = get_signature_algorithm(padding, algorithm)
419422
digest = Hash(algorithm)
420423
digest.update(data)

0 commit comments

Comments
 (0)