Skip to content

Commit fd83f3d

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

4 files changed

Lines changed: 18 additions & 33 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/_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)

sdk/keyvault/azure-keyvault-keys/pyproject.toml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# --------------------------------------------------------------------------
77

88
[build-system]
9-
requires = ["setuptools>=61.0.0", "wheel"] # Requires 61.0.0 for dynamic version
9+
requires = ["setuptools>=77.0.3", "wheel"]
1010
build-backend = "setuptools.build_meta"
1111

1212
[project]
@@ -44,7 +44,7 @@ dynamic = [
4444
repository = "https://github.com/Azure/azure-sdk-for-python"
4545

4646
[tool.setuptools.dynamic]
47-
version = {attr = "azure.keyvault.keys._version.VERSION"}
47+
version = {attr = "azure.keyvault.keys._generated._version.VERSION"}
4848
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
4949

5050
[tool.setuptools.packages.find]
@@ -56,6 +56,7 @@ exclude = [
5656
"doc*",
5757
"azure",
5858
"azure.keyvault",
59+
"azure.keyvault.keys",
5960
]
6061

6162
[tool.setuptools.package-data]
@@ -64,23 +65,6 @@ pytyped = ["py.typed"]
6465
[tool.azure-sdk-build]
6566
pyright = false
6667

67-
[tool.uv.sources]
68-
azure-core = { path = "../../core/azure-core" }
69-
azure-keyvault-nspkg = { path = "../../nspkg/azure-keyvault-nspkg" }
70-
azure-sdk-tools = { path = "../../../eng/tools/azure-sdk-tools" }
71-
72-
[dependency-groups]
73-
dev = [
74-
"aiohttp>=3.0",
75-
"azure-core",
76-
"azure-identity>=1.24.0",
77-
"azure-keyvault-nspkg",
78-
"azure-mgmt-keyvault==10.1.0",
79-
"azure-sdk-tools",
80-
"parameterized>=0.7.3",
81-
"python-dateutil>=2.8.0",
82-
]
83-
8468
[tool.azure-sdk-conda]
8569
in_bundle = true
8670
bundle_name = "azure-keyvault"

0 commit comments

Comments
 (0)