Skip to content

Commit d530344

Browse files
authored
[keyvault] style: format strings to f-string
# Description close Azure#3 File changed: `azure-keyvault-keys/samples/hello_world_async.py` I have added f-string formatting to `azure-keyvault-keys/samples/hello_world_async.py`. It seems I have pulled additional changes from the main Azure repo. I will check to see if I can remove the commits by other contributors. Thank you. # All SDK Contribution checklist: - [x] **The pull request does not introduce [breaking changes]** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### [Testing Guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md##building-and-testing) - [x] Pull request includes test coverage for the included changes.
1 parent ea34c9c commit d530344

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

sdk/keyvault/azure-keyvault-keys/samples/hello_world_async.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ async def run_sample():
5050
key_ops = ["encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey"]
5151
key_name = "rsaKeyNameAsync"
5252
rsa_key = await client.create_rsa_key(key_name, size=key_size, key_operations=key_ops)
53-
print("RSA Key with name '{0}' created of type '{1}'.".format(rsa_key.name, rsa_key.key_type))
53+
print(f"RSA Key with name '{rsa_key.name}' created of type '{rsa_key.key_type}'.")
5454

5555
# Let's create an Elliptic Curve key with algorithm curve type P-256.
5656
# if the key already exists in the Key Vault, then a new version of the key is created.
5757
print("\n.. Create an EC Key")
5858
key_curve = "P-256"
5959
key_name = "ECKeyNameAsync"
6060
ec_key = await client.create_ec_key(key_name, curve=key_curve)
61-
print("EC Key with name '{0}' created of type {1}.".format(ec_key.name, ec_key.key_type))
61+
print(f"EC Key with name '{ec_key.name}' created of type {ec_key.key_type}.")
6262

6363
# Let's get the rsa key details using its name
6464
print("\n.. Get a Key using it's name")
6565
rsa_key = await client.get_key(rsa_key.name)
66-
print("Key with name '{0}' was found.".format(rsa_key.name))
66+
print(f"Key with name '{rsa_key.name}' was found.")
6767

6868
# Let's say we want to update the expiration time for the EC key and disable the key to be usable
6969
# for cryptographic operations. The update method allows the user to modify the metadata (key attributes)
@@ -73,22 +73,14 @@ async def run_sample():
7373
updated_ec_key = await client.update_key_properties(
7474
ec_key.name, version=ec_key.properties.version, expires_on=expires_on, enabled=False
7575
)
76-
print(
77-
"Key with name '{0}' was updated on date '{1}'".format(
78-
updated_ec_key.name, updated_ec_key.properties.updated_on
79-
)
80-
)
81-
print(
82-
"Key with name '{0}' was updated to expire on '{1}'".format(
83-
updated_ec_key.name, updated_ec_key.properties.expires_on
84-
)
85-
)
76+
print(f"Key with name '{updated_ec_key.name}' was updated on date '{updated_ec_key.properties.updated_on}'")
77+
print(f"Key with name '{updated_ec_key.name}' was updated to expire on '{updated_ec_key.properties.expires_on}'")
8678

8779
# The keys are no longer used, let's delete them
8880
print("\n.. Deleting keys")
8981
for key_name in (ec_key.name, rsa_key.name):
9082
deleted_key = await client.delete_key(key_name)
91-
print("\nDeleted '{}'".format(deleted_key.name))
83+
print(f"\nDeleted '{deleted_key.name}'")
9284

9385
print("\nrun_sample done")
9486
await credential.close()

0 commit comments

Comments
 (0)