From 57a84e722641c7bf811165e6e72b37f6dba5ebc8 Mon Sep 17 00:00:00 2001 From: lbhsos Date: Thu, 28 Jul 2022 17:16:28 +0900 Subject: [PATCH] [keyvalut] Enhance code style for sample file Modernize to follow with up-to-date coding style for sdk/keyvault/azure-keyvault-keys/samples/list_operations.py - change format to f-string Closes: #6 --- .../azure-keyvault-keys/samples/list_operations.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-keys/samples/list_operations.py b/sdk/keyvault/azure-keyvault-keys/samples/list_operations.py index 205e19053112c..837c6ef54a4a5 100644 --- a/sdk/keyvault/azure-keyvault-keys/samples/list_operations.py +++ b/sdk/keyvault/azure-keyvault-keys/samples/list_operations.py @@ -45,8 +45,8 @@ print("\n.. Create Key") rsa_key = client.create_rsa_key("rsaKeyName") ec_key = client.create_ec_key("ecKeyName") -print("Key with name '{0}' was created of type '{1}'.".format(rsa_key.name, rsa_key.key_type)) -print("Key with name '{0}' was created of type '{1}'.".format(ec_key.name, ec_key.key_type)) +print(f"Key with name '{rsa_key.name}' was created of type '{rsa_key.key_type}'.") +print(f"Key with name '{ec_key.name}' was created of type '{ec_key.key_type}'.") # You need to check the type of all the keys in the vault. # Let's list the keys and print their key types. @@ -57,20 +57,20 @@ for key in keys: retrieved_key = client.get_key(key.name) print( - "Key with name '{0}' with type '{1}' was found.".format(retrieved_key.name, retrieved_key.key_type) + f"Key with name '{retrieved_key.name}' with type '{retrieved_key.key_type}' was found." ) # The rsa key size now should now be 3072, default - 2048. So you want to update the key in Key Vault to ensure # it reflects the new key size. Calling create_rsa_key on an existing key creates a new version of the key in # the Key Vault with the new key size. new_key = client.create_rsa_key(rsa_key.name, size=3072) -print("New version was created for Key with name '{0}' with the updated size.".format(new_key.name)) +print(f"New version was created for Key with name '{new_key.name}' with the updated size.") # You should have more than one version of the rsa key at this time. Lets print all the versions of this key. print("\n.. List versions of a key using its name") key_versions = client.list_properties_of_key_versions(rsa_key.name) for key in key_versions: - print("Key '{0}' has version: '{1}'".format(key.name, key.version)) + print(f"Key '{key.name}' has version: '{key.version}'") # Both the rsa key and ec key are not needed anymore. Let's delete those keys. print("\n.. Delete the created keys...") @@ -81,4 +81,4 @@ print("\n.. List deleted keys from the Key Vault (requires soft-delete)") deleted_keys = client.list_deleted_keys() for deleted_key in deleted_keys: - print("Key with name '{0}' has recovery id '{1}'".format(deleted_key.name, deleted_key.recovery_id)) + print(f"Key with name '{deleted_key.name}' has recovery id '{deleted_key.recovery_id}'")