Repository: softlayer/softlayer-python
Pull request #1978 (2023-06-08 19:17:46)

F-Strings - call-api / config /  dns / file 
Hi @allmightyspiff ,

I have updated line of code from .format() to f"{}" string.

Please review it and approve this pull request.

Please find the details.

Details:

Title: Fstrings - call api, cdn, config, core, custom types, dns, event log, file and formatting commands
Start using python f-strings https://github.com/softlayer/softlayer-python/issues/1977

Description:

**call** api:
SoftLayer/CLI/call_api.py: format(_filter, type(_filter)))
SoftLayer/CLI/call_api.py: raise exceptions.CLIAbort(""{}" is not valid JSON. {}".format(value, error))
SoftLayer/CLI/call_api.py: format(parameter, error), fg='red')

**cdn:**
SoftLayer/CLI/cdn/delete.py: env.fout("Cdn with uniqueId: {} was deleted.".format(unique_id))

**config:**
SoftLayer/CLI/config/setup.py: env.fout("Creating a Classic Infrastrucutre API key for {}".format(user['username']))
SoftLayer/CLI/config/setup.py: headers['Authorization'] = 'Bearer {}'.format(a_token)
SoftLayer/CLI/config/setup.py: env.fout("{}: {} ({})".format(counter, utils.lookup(selected, 'entity', 'name'), ims_id))
SoftLayer/CLI/config/setup.py: print("Using account {}".format(utils.lookup(selected, 'entity', 'name')))
SoftLayer/CLI/config/setup.py: env.fout("Get a one-time code from {} to proceed.".format(passcode_url))
SoftLayer/CLI/config/setup.py: env.fout("Creating a Classic Infrastrucutre API key for {}".format(user['username']))

**core:**
SoftLayer/CLI/core.py: latest = 'v{}'.format(json_result['info']['version'])
SoftLayer/CLI/core.py: click.secho("Current: {prog} {current}\nLatest: {prog} {latest}".format(
SoftLayer/CLI/core.py: call_table = formatting.Table(['', '{}::{}'.format(call.service, call.method)], align="left")

**custom** types:
SoftLayer/CLI/custom_types.py: self.fail('{} is not a valid network'.format(value), param, ctx)

**dns:**
**As Suggested, Skipping Starts From Here because it is complicated**
SoftLayer/CLI/dns/zone_import.py: click.secho("Parsed: %s" % RECORD_FMT.format(**record), fg="green")
SoftLayer/CLI/dns/zone_import.py: click.secho(click.style("Created: %s" % RECORD_FMT.format(**record), fg='green'))
SoftLayer/CLI/dns/zone_import.py: click.secho(click.style("Failed: %s" % RECORD_FMT.format(**record), fg='red'))
**As Suggested, Skipping Ends to Here because it is complicated**

SoftLayer/CLI/dns/zone_list.py: zone_date = "{}-{}-{}T00:00:00-06:00".format(zone_serial[0:4], zone_serial[4:6], zone_serial[6:8])

**event** log:
SoftLayer/CLI/event_log/get.py: click.secho("'{0}','{1}','{2}','{3}','{4}','{5}'".format(
SoftLayer/CLI/event_log/get.py: click.secho("'{0}','{1}','{2}','{3}','{4}'".format(

**file:**
SoftLayer/CLI/file/access/list.py: help='Columns to display. Options: {0}'.format(
SoftLayer/CLI/file/detail.py: notes = '{}'.format(file_volume.get('notes', ''))
SoftLayer/CLI/file/duplicate.py: click.echo("Order #{0} placed successfully!".format(
SoftLayer/CLI/file/list.py: help='Columns to display. Options: {0}'.format(
SoftLayer/CLI/file/modify.py: click.echo("Order #{0} placed successfully!".format(order['placedOrder']['id']))
SoftLayer/CLI/file/order.py: click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
SoftLayer/CLI/file/order.py: click.echo("Order #{0} placed successfully!".format(
SoftLayer/CLI/file/order.py: 'is ready.'.format(order['placedOrder']['id']))
SoftLayer/CLI/file/replication/locations.py: help='Columns to display. Options: {0}'.format(
SoftLayer/CLI/file/replication/order.py: click.echo("Order #{0} placed successfully!".format(
SoftLayer/CLI/file/replication/partners.py: help='Columns to display. Options: {0}'.format(
SoftLayer/CLI/file/snapshot/get_notify_status.py: click.echo("Disabled: Snapshots space usage threshold is disabled for volume {}".format(volume_id))
SoftLayer/CLI/file/snapshot/get_notify_status.py: click.echo("Enabled: Snapshots space usage threshold is enabled for volume {}".format(volume_id))
SoftLayer/CLI/file/snapshot/list.py: help='Columns to display. Options: {0}'.format(
SoftLayer/CLI/file/snapshot/order.py: click.echo("Order #{0} placed successfully!".format(

**formatting:**
**Excluding because it is not a .format()**
**SoftLayer/CLI/formatting.py: return csv_output_format(data)**

SoftLayer/CLI/formatting.py: return "{:.2f} {}".format(value, units[unit_index])
SoftLayer/CLI/formatting.py: return "{:.2f} {}".format(total_value, total_unit)

**Excluding because it is not a .format()**
**SoftLayer/CLI/formatting.py:def csv_output_format(data, delimiter=','):
SoftLayer/CLI/formatting.py: write_csv_format(sys.stdout, data, delimiter)
SoftLayer/CLI/formatting.py: write_csv_format(string_io, value, delimiter, quoting=csv.QUOTE_MINIMAL)
SoftLayer/CLI/formatting.py:def write_csv_format(support_output, data, delimiter, quoting=csv.QUOTE_NONNUMERIC):**


Linked Big Issues: https://github.com/softlayer/softlayer-python/issues/1547
Child Issue: #1977

Thanks,
Ramkishor Chaladi.


Patch:
diff --git a/SoftLayer/CLI/account/billing_items.py b/SoftLayer/CLI/account/billing_items.py
index 0f16af2f..9f754b1d 100644
--- a/SoftLayer/CLI/account/billing_items.py
+++ b/SoftLayer/CLI/account/billing_items.py
@@ -42,7 +42,7 @@ def item_table(items, ordered=None):
     table.align['Category Code'] = 'l'
     for item in items:
         description = item.get('description')
-        fqdn = "{}.{}".format(item.get('hostName', ''), item.get('domainName', ''))
+        fqdn = f"{item.get('hostName', '')}.{item.get('domainName', '')}"
         if fqdn != ".":
             description = fqdn
         user = utils.lookup(item, 'orderItem', 'order', 'userRecord')
diff --git a/SoftLayer/CLI/account/cancel_item.py b/SoftLayer/CLI/account/cancel_item.py
index 6b533557..dddde0c6 100644
--- a/SoftLayer/CLI/account/cancel_item.py
+++ b/SoftLayer/CLI/account/cancel_item.py
@@ -17,4 +17,4 @@ def cli(env, identifier):
     item = manager.cancel_item(identifier)
 
     if item:
-        env.fout("Item: {} was cancelled.".format(identifier))
+        env.fout(f"Item: {identifier} was cancelled.")
diff --git a/SoftLayer/CLI/account/item_detail.py b/SoftLayer/CLI/account/item_detail.py
index 864a6b92..a67ed6f6 100644
--- a/SoftLayer/CLI/account/item_detail.py
+++ b/SoftLayer/CLI/account/item_detail.py
@@ -23,13 +23,13 @@ def item_table(item):
     """Formats a table for billing items"""
 
     date_format = '%Y-%m-%d'
-    table = formatting.Table(["Key", "Value"], title="{}".format(item.get('description', 'Billing Item')))
+    table = formatting.Table(["Key", "Value"], title=f"{item.get('description', 'Billing Item')}")
     table.add_row(['createDate', utils.clean_time(item.get('createDate'), date_format, date_format)])
     table.add_row(['cycleStartDate', utils.clean_time(item.get('cycleStartDate'), date_format, date_format)])
     table.add_row(['cancellationDate', utils.clean_time(item.get('cancellationDate'), date_format, date_format)])
     table.add_row(['description', item.get('description')])
     table.align = 'l'
-    fqdn = "{}.{}".format(item.get('hostName', ''), item.get('domainName', ''))
+    fqdn = f"{item.get('hostName', '')}.{item.get('domainName', '')}"
     if fqdn != ".":
         table.add_row(['FQDN', fqdn])
 
@@ -43,7 +43,7 @@ def item_table(item):
     ordered_by = "IBM"
     user = utils.lookup(item, 'orderItem', 'order', 'userRecord')
     if user:
-        ordered_by = "{} ({})".format(user.get('displayName'), utils.lookup(user, 'userStatus', 'name'))
+        ordered_by = f"{user.get('displayName')} ({utils.lookup(user, 'userStatus', 'name')})"
     table.add_row(['Ordered By', ordered_by])
     table.add_row(['Notes', item.get('notes')])
     table.add_row(['Location', utils.lookup(item, 'location', 'name')])
diff --git a/SoftLayer/CLI/bandwidth/pools.py b/SoftLayer/CLI/bandwidth/pools.py
index bd7425ee..8a081d94 100644
--- a/SoftLayer/CLI/bandwidth/pools.py
+++ b/SoftLayer/CLI/bandwidth/pools.py
@@ -39,19 +39,19 @@ def cli(env):
         name = item.get('name')
         region = utils.lookup(item, 'locationGroup', 'name')
         servers = manager.get_bandwidth_pool_counts(identifier=item.get('id'))
-        allocation = "{} GB".format(item.get('totalBandwidthAllocated', 0))
+        allocation = f"{item.get('totalBandwidthAllocated', 0)} GB"
 
         current = utils.lookup(item, 'billingCyclePublicBandwidthUsage', 'amountOut')
         if current is not None:
-            current = "{} GB".format(current)
+            current = f"{current} GB"
         else:
             current = "0 GB"
 
-        projected = "{} GB".format(item.get('projectedPublicBandwidthUsage', 0))
+        projected = f"{item.get('projectedPublicBandwidthUsage', 0)} GB"
 
         cost = utils.lookup(item, 'billingItem', 'nextInvoiceTotalRecurringAmount')
         if cost is not None:
-            cost = "${}".format(cost)
+            cost = f"${cost}"
         else:
             cost = "$0.0"
 
diff --git a/SoftLayer/CLI/bandwidth/pools_detail.py b/SoftLayer/CLI/bandwidth/pools_detail.py
index 871bb54d..c1e739bf 100644
--- a/SoftLayer/CLI/bandwidth/pools_detail.py
+++ b/SoftLayer/CLI/bandwidth/pools_detail.py
@@ -24,15 +24,15 @@ def cli(env, identifier):
     table.add_row(['Id', bandwidths['id']])
     table.add_row(['Name', bandwidths['name']])
     table.add_row(['Create Date', utils.clean_time(bandwidths.get('createDate'), '%Y-%m-%d')])
-    current = "{} GB".format(utils.lookup(bandwidths, 'billingCyclePublicBandwidthUsage', 'amountOut'))
+    current = f"{utils.lookup(bandwidths, 'billingCyclePublicBandwidthUsage', 'amountOut')} GB"
     if current is None:
         current = '-'
     table.add_row(['Current Usage', current])
-    projected = "{} GB".format(bandwidths.get('projectedPublicBandwidthUsage', 0))
+    projected = f"{bandwidths.get('projectedPublicBandwidthUsage', 0)} GB"
     if projected is None:
         projected = '-'
     table.add_row(['Projected  Usage', projected])
-    inbound = "{} GB".format(bandwidths.get('inboundPublicBandwidthUsage', 0))
+    inbound = f"{bandwidths.get('inboundPublicBandwidthUsage', 0)} GB"
     if inbound is None:
         inbound = '-'
     table.add_row(['Inbound   Usage', inbound])
@@ -58,8 +58,8 @@ def _bw_table(bw_data):
     """Generates a bandwidth useage table"""
     table_data = formatting.Table(['Id', 'HostName', "IP Address", 'Amount', "Current Usage"])
     for bw_point in bw_data:
-        amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount'))
-        current = "{} GB".format(bw_point.get('outboundBandwidthUsage', 0))
+        amount = f"{utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount')} GB"
+        current = f"{bw_point.get('outboundBandwidthUsage', 0)} GB"
         ip_address = bw_point.get('primaryIpAddress')
         if ip_address is None:
             ip_address = '-'
@@ -71,8 +71,8 @@ def _virtual_table(bw_data):
     """Generates a virtual bandwidth usage table"""
     table_data = formatting.Table(['Id', 'HostName', "IP Address", 'Amount', "Current Usage"])
     for bw_point in bw_data:
-        amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount'))
-        current = "{} GB".format(bw_point.get('outboundBandwidthUsage', 0))
+        amount = f"{utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount')} GB"
+        current = f"{bw_point.get('outboundBandwidthUsage', 0)} GB"
         ip_address = bw_point.get('primaryIpAddress')
         if ip_address is None:
             ip_address = '-'
diff --git a/SoftLayer/CLI/block/access/list.py b/SoftLayer/CLI/block/access/list.py
index 0150f3f2..5846a349 100644
--- a/SoftLayer/CLI/block/access/list.py
+++ b/SoftLayer/CLI/block/access/list.py
@@ -14,12 +14,10 @@
 @click.argument('volume_id')
 @click.option('--columns',
               callback=column_helper.get_formatter(storage_utils.COLUMNS),
-              help='Columns to display. Options are: {0}.'.format(
-                  ', '.join(column.name for column in storage_utils.COLUMNS)),
+              help=f"Columns to display. Options are: {', '.join(column.name for column in storage_utils.COLUMNS)}.",
               default=','.join(storage_utils.DEFAULT_COLUMNS))
 @click.option('--sortby',
-              help='Column to sort by. Options are: {0}.'.format(
-                  ', '.join(column.name for column in storage_utils.COLUMNS)),
+              help=f"Column to sort by. Options are: {', '.join(column.name for column in storage_utils.COLUMNS)}.",
               default='name')
 @environment.pass_env
 def cli(env, columns, sortby, volume_id):
diff --git a/SoftLayer/CLI/block/detail.py b/SoftLayer/CLI/block/detail.py
index c41162ef..7752e1b5 100644
--- a/SoftLayer/CLI/block/detail.py
+++ b/SoftLayer/CLI/block/detail.py
@@ -112,7 +112,7 @@ def cli(env, volume_id):
             original_volume_info.add_row(['Original Snapshot Name', block_volume['originalSnapshotName']])
         table.add_row(['Original Volume Properties', original_volume_info])
 
-    notes = '{}'.format(block_volume.get('notes', ''))
+    notes = f"{block_volume.get('notes', '')}"
     table.add_row(['Notes', notes])
 
     env.fout(table)
diff --git a/SoftLayer/CLI/block/duplicate.py b/SoftLayer/CLI/block/duplicate.py
index b92d6413..152a557a 100644
--- a/SoftLayer/CLI/block/duplicate.py
+++ b/SoftLayer/CLI/block/duplicate.py
@@ -89,8 +89,7 @@ def cli(env, origin_volume_id, origin_snapshot_id, duplicate_size,
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
     else:
diff --git a/SoftLayer/CLI/block/list.py b/SoftLayer/CLI/block/list.py
index 274ed57b..992d421a 100644
--- a/SoftLayer/CLI/block/list.py
+++ b/SoftLayer/CLI/block/list.py
@@ -60,8 +60,7 @@
 @click.option('--sortby', help='Column to sort by', default='username')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, sortby, columns, datacenter, username, storage_type, order):
diff --git a/SoftLayer/CLI/block/modify.py b/SoftLayer/CLI/block/modify.py
index 06383332..9bc785f3 100644
--- a/SoftLayer/CLI/block/modify.py
+++ b/SoftLayer/CLI/block/modify.py
@@ -50,7 +50,7 @@ def cli(env, volume_id, new_size, new_iops, new_tier):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
     else:
diff --git a/SoftLayer/CLI/block/order.py b/SoftLayer/CLI/block/order.py
index 6191bc4e..528e4e1f 100644
--- a/SoftLayer/CLI/block/order.py
+++ b/SoftLayer/CLI/block/order.py
@@ -72,7 +72,7 @@ def cli(env, storage_type, size, iops, tier, os_type,
         hourly_billing_flag = True
 
     if service_offering != 'storage_as_a_service':
-        click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
+        click.secho(f"{service_offering} is a legacy storage offering", fg='red')
         if hourly_billing_flag:
             raise exceptions.CLIAbort(
                 'Hourly billing is only available for the storage_as_a_service service offering'
@@ -123,12 +123,10 @@ def cli(env, storage_type, size, iops, tier, os_type,
             raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
-        click.echo(
-            '\nYou may run "slcli block volume-list --order {0}" to find this block volume after it '
-            'is ready.'.format(order['placedOrder']['id']))
+        click.echo(f"\nYou may run 'slcli block volume-list --order {order['placedOrder']['id']}' "
+                   "to find this block volume after it is ready.")
     else:
         click.echo("Order could not be placed! Please verify your options and try again.")
diff --git a/SoftLayer/CLI/block/replication/locations.py b/SoftLayer/CLI/block/replication/locations.py
index 12475741..0767d081 100644
--- a/SoftLayer/CLI/block/replication/locations.py
+++ b/SoftLayer/CLI/block/replication/locations.py
@@ -24,8 +24,7 @@
 @click.argument('volume-id')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @click.option('--sortby', help='Column to sort by', default='Long Name')
 @environment.pass_env
diff --git a/SoftLayer/CLI/block/replication/order.py b/SoftLayer/CLI/block/replication/order.py
index c678a397..e3c666f2 100644
--- a/SoftLayer/CLI/block/replication/order.py
+++ b/SoftLayer/CLI/block/replication/order.py
@@ -70,8 +70,7 @@ def cli(env, volume_id, snapshot_schedule, datacenter, tier, os_type, iops):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            utils.lookup(order, 'placedOrder', 'id')))
+        click.echo(f"Order #{utils.lookup(order, 'placedOrder', 'id')} placed successfully!")
         for item in utils.lookup(order, 'placedOrder', 'items'):
             click.echo(" > %s" % item.get('description'))
     else:
diff --git a/SoftLayer/CLI/block/replication/partners.py b/SoftLayer/CLI/block/replication/partners.py
index bece5e9c..c5ae5075 100644
--- a/SoftLayer/CLI/block/replication/partners.py
+++ b/SoftLayer/CLI/block/replication/partners.py
@@ -16,8 +16,7 @@
 @click.argument('volume-id')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @click.option('--sortby', help='Column to sort by', default='Username')
 @environment.pass_env
diff --git a/SoftLayer/CLI/block/snapshot/get_notify_status.py b/SoftLayer/CLI/block/snapshot/get_notify_status.py
index e45e73b8..9c21085b 100644
--- a/SoftLayer/CLI/block/snapshot/get_notify_status.py
+++ b/SoftLayer/CLI/block/snapshot/get_notify_status.py
@@ -15,6 +15,6 @@ def cli(env, volume_id):
     enabled = block_manager.get_volume_snapshot_notification_status(volume_id)
 
     if enabled == 0:
-        click.echo("Disabled: Snapshots space usage threshold is disabled for volume {}".format(volume_id))
+        click.echo(f"Disabled: Snapshots space usage threshold is disabled for volume {volume_id}")
     else:
-        click.echo("Enabled: Snapshots space usage threshold is enabled for volume {}".format(volume_id))
+        click.echo(f"Enabled: Snapshots space usage threshold is enabled for volume {volume_id}")
diff --git a/SoftLayer/CLI/block/snapshot/list.py b/SoftLayer/CLI/block/snapshot/list.py
index 90d42a91..e9eca598 100644
--- a/SoftLayer/CLI/block/snapshot/list.py
+++ b/SoftLayer/CLI/block/snapshot/list.py
@@ -32,8 +32,7 @@
               default='created')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, volume_id, sortby, columns):
diff --git a/SoftLayer/CLI/block/snapshot/order.py b/SoftLayer/CLI/block/snapshot/order.py
index 4e2ce68a..a443c95e 100644
--- a/SoftLayer/CLI/block/snapshot/order.py
+++ b/SoftLayer/CLI/block/snapshot/order.py
@@ -53,8 +53,7 @@ def cli(env, volume_id, size, tier, upgrade, iops):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
         if 'status' in order['placedOrder'].keys():
diff --git a/SoftLayer/CLI/block/subnets/assign.py b/SoftLayer/CLI/block/subnets/assign.py
index 567b0301..daf554df 100644
--- a/SoftLayer/CLI/block/subnets/assign.py
+++ b/SoftLayer/CLI/block/subnets/assign.py
@@ -24,14 +24,14 @@ def cli(env, access_id, subnet_id):
         assigned_subnets = block_manager.assign_subnets_to_acl(access_id, subnet_ids)
 
         for subnet in assigned_subnets:
-            message = "Successfully assigned subnet id: {} to allowed host id: {}".format(subnet, access_id)
+            message = f"Successfully assigned subnet id: {subnet} to allowed host id: {access_id}"
             click.echo(message)
 
         failed_to_assign_subnets = list(set(subnet_ids) - set(assigned_subnets))
         for subnet in failed_to_assign_subnets:
-            message = "Failed to assign subnet id: {} to allowed host id: {}".format(subnet, access_id)
+            message = f"Failed to assign subnet id: {subnet} to allowed host id: {access_id}"
             click.echo(message)
 
     except SoftLayer.SoftLayerAPIError as ex:
-        message = "Unable to assign subnets.\nReason: {}".format(ex.faultString)
+        message = f"Unable to assign subnets.\nReason: {ex.faultString}"
         click.echo(message)
diff --git a/SoftLayer/CLI/block/subnets/list.py b/SoftLayer/CLI/block/subnets/list.py
index afc19c73..a60142f7 100644
--- a/SoftLayer/CLI/block/subnets/list.py
+++ b/SoftLayer/CLI/block/subnets/list.py
@@ -31,9 +31,9 @@ def cli(env, access_id):
 
         table = formatting.Table(COLUMNS)
         for subnet in subnets:
-            row = ["{0}".format(subnet['id']),
-                   "{0}".format(subnet['networkIdentifier']),
-                   "{0}".format(subnet['cidr'])]
+            row = [f"{subnet['id']}",
+                   f"{subnet['networkIdentifier']}",
+                   f"{subnet['cidr']}"]
             table.add_row(row)
 
         env.fout(table)
diff --git a/SoftLayer/CLI/block/subnets/remove.py b/SoftLayer/CLI/block/subnets/remove.py
index 6e3d0b1a..92d825af 100644
--- a/SoftLayer/CLI/block/subnets/remove.py
+++ b/SoftLayer/CLI/block/subnets/remove.py
@@ -24,14 +24,14 @@ def cli(env, access_id, subnet_id):
         removed_subnets = block_manager.remove_subnets_from_acl(access_id, subnet_ids)
 
         for subnet in removed_subnets:
-            message = "Successfully removed subnet id: {} for allowed host id: {}".format(subnet, access_id)
+            message = f"Successfully removed subnet id: {subnet} for allowed host id: {access_id}"
             click.echo(message)
 
         failed_to_remove_subnets = list(set(subnet_ids) - set(removed_subnets))
         for subnet in failed_to_remove_subnets:
-            message = "Failed to remove subnet id: {} for allowed host id: {}".format(subnet, access_id)
+            message = f"Failed to remove subnet id: {subnet} for allowed host id: {access_id}"
             click.echo(message)
 
     except SoftLayer.SoftLayerAPIError as ex:
-        message = "Unable to remove subnets.\nReason: {}".format(ex.faultString)
+        message = f"Unable to remove subnets.\nReason: {ex.faultString}"
         click.echo(message)
diff --git a/SoftLayer/CLI/call_api.py b/SoftLayer/CLI/call_api.py
index 70ff1553..e6c007e2 100644
--- a/SoftLayer/CLI/call_api.py
+++ b/SoftLayer/CLI/call_api.py
@@ -77,10 +77,9 @@ def _validate_filter(ctx, param, value):  # pylint: disable=unused-argument
         try:
             _filter = json.loads(value)
             if not isinstance(_filter, dict):
-                raise exceptions.CLIAbort("\"{}\" should be a JSON object, but is a {} instead.".
-                                          format(_filter, type(_filter)))
+                raise exceptions.CLIAbort(f"\"{_filter}\" should be a JSON object, but is a {type(_filter)} instead.")
         except json.JSONDecodeError as error:
-            raise exceptions.CLIAbort("\"{}\" is not valid JSON. {}".format(value, error))
+            raise exceptions.CLIAbort(f"\"{value}\" is not valid JSON. {error}")
 
     return _filter
 
@@ -96,8 +95,8 @@ def _validate_parameters(ctx, param, value):  # pylint: disable=unused-argument
                 try:
                     parameter = json.loads(parameter)
                 except json.JSONDecodeError as error:
-                    click.secho("{} looked like json, but was invalid, passing to API as is. {}".
-                                format(parameter, error), fg='red')
+                    click.secho(f"{parameter} looked like json, but was invalid, passing to API as is. {error}",
+                                fg='red')
         validated_values.append(parameter)
     return validated_values
 
diff --git a/SoftLayer/CLI/cdn/delete.py b/SoftLayer/CLI/cdn/delete.py
index b089e9ef..0dd2e91d 100644
--- a/SoftLayer/CLI/cdn/delete.py
+++ b/SoftLayer/CLI/cdn/delete.py
@@ -18,4 +18,4 @@ def cli(env, unique_id):
     cdn = manager.delete_cdn(unique_id)
 
     if cdn:
-        env.fout("Cdn with uniqueId: {} was deleted.".format(unique_id))
+        env.fout(f"Cdn with uniqueId: {unique_id} was deleted.")
diff --git a/SoftLayer/CLI/config/setup.py b/SoftLayer/CLI/config/setup.py
index f06825ab..7ba52ee9 100644
--- a/SoftLayer/CLI/config/setup.py
+++ b/SoftLayer/CLI/config/setup.py
@@ -171,7 +171,7 @@ def ibmid_login(env):
     user = client.call('SoftLayer_Account', 'getCurrentUser', mask="mask[id,username,apiAuthenticationKeys]")
 
     if len(user.get('apiAuthenticationKeys', [])) == 0:
-        env.fout("Creating a Classic Infrastrucutre API key for {}".format(user['username']))
+        env.fout(f"Creating a Classic Infrastrucutre API key for {user['username']}")
         api_key = client.call('User_Customer', 'addApiAuthenticationKey', id=user['id'])
     else:
         api_key = user['apiAuthenticationKeys'][0]['authenticationKey']
@@ -188,7 +188,7 @@ def get_accounts(env, a_token):
         'User-Agent': USER_AGENT,
         'Accept': 'application/json'
     }
-    headers['Authorization'] = 'Bearer {}'.format(a_token)
+    headers['Authorization'] = f'Bearer {a_token}'
     response = iam_client.request(
         'GET',
         'https://accounts.cloud.ibm.com/v1/accounts',
@@ -212,7 +212,7 @@ def get_accounts(env, a_token):
                     ims_id = link.get('id')
             if ims_id is None:
                 ims_id = "Unlinked"
-            env.fout("{}: {} ({})".format(counter, utils.lookup(selected, 'entity', 'name'), ims_id))
+            env.fout(f"{counter}: {utils.lookup(selected, 'entity', 'name')} ({ims_id})")
             counter = counter + 1
         ims_id = None  # Reset ims_id to avoid any mix-match or something.
         choice = click.prompt('Enter a number', type=int)
@@ -225,7 +225,7 @@ def get_accounts(env, a_token):
         if link.get('origin') == "IMS":
             ims_id = link.get('id')
 
-    print("Using account {}".format(utils.lookup(selected, 'entity', 'name')))
+    print(f"Using account {utils.lookup(selected, 'entity', 'name')}")
     return {"account_id": account_id, "ims_id": ims_id}
 
 
@@ -253,7 +253,7 @@ def get_sso_url():
 def sso_login(env):
     """Uses a SSO token to get a SL apikey"""
     passcode_url = get_sso_url()
-    env.fout("Get a one-time code from {} to proceed.".format(passcode_url))
+    env.fout(f"Get a one-time code from {passcode_url} to proceed.")
     open_browser = env.input("Open the URL in the default browser? [Y/n]", default='Y')
     if open_browser.lower() == 'y':
         webbrowser.open(passcode_url)
@@ -274,7 +274,7 @@ def sso_login(env):
     user = client.call('SoftLayer_Account', 'getCurrentUser', mask="mask[id,username,apiAuthenticationKeys]")
 
     if len(user.get('apiAuthenticationKeys', [])) == 0:
-        env.fout("Creating a Classic Infrastrucutre API key for {}".format(user['username']))
+        env.fout(f"Creating a Classic Infrastrucutre API key for {user['username']}")
         api_key = client.call('User_Customer', 'addApiAuthenticationKey', id=user['id'])
     else:
         api_key = user['apiAuthenticationKeys'][0]['authenticationKey']
diff --git a/SoftLayer/CLI/core.py b/SoftLayer/CLI/core.py
index bab2a9d4..df979324 100644
--- a/SoftLayer/CLI/core.py
+++ b/SoftLayer/CLI/core.py
@@ -46,7 +46,7 @@ def get_latest_version():
     try:
         result = requests.get('https://pypi.org/pypi/SoftLayer/json',  timeout=60)
         json_result = result.json()
-        latest = 'v{}'.format(json_result['info']['version'])
+        latest = f"v{json_result['info']['version']}"
     except Exception:
         latest = "Unable to get version from pypi."
     return latest
@@ -65,8 +65,7 @@ def get_version_message(ctx, param, value):
         return
     current = SoftLayer.consts.VERSION
     latest = get_latest_version()
-    click.secho("Current: {prog} {current}\nLatest:  {prog} {latest}".format(
-        prog=PROG_NAME, current=current, latest=latest))
+    click.secho(f"Current: {PROG_NAME} {current}\nLatest:  {PROG_NAME} {latest}")
     ctx.exit()
 
 
@@ -158,7 +157,7 @@ def output_diagnostics(env, result, verbose=0, **kwargs):
 
     if verbose > 1:
         for call in env.client.transport.get_last_calls():
-            call_table = formatting.Table(['', '{}::{}'.format(call.service, call.method)], align="left")
+            call_table = formatting.Table(['', f'{call.service}::{call.method}'], align="left")
             nice_mask = ''
             if call.mask is not None:
                 nice_mask = call.mask
diff --git a/SoftLayer/CLI/custom_types.py b/SoftLayer/CLI/custom_types.py
index e0f27b04..17b2e566 100644
--- a/SoftLayer/CLI/custom_types.py
+++ b/SoftLayer/CLI/custom_types.py
@@ -30,4 +30,4 @@ def convert(self, value, param, ctx):
             ip_address, cidr = address
             return (ip_address, int(cidr))
         except ValueError:
-            self.fail('{} is not a valid network'.format(value), param, ctx)
+            self.fail(f'{value} is not a valid network', param, ctx)
diff --git a/SoftLayer/CLI/dns/zone_list.py b/SoftLayer/CLI/dns/zone_list.py
index 6a1db571..4ec56147 100644
--- a/SoftLayer/CLI/dns/zone_list.py
+++ b/SoftLayer/CLI/dns/zone_list.py
@@ -24,7 +24,7 @@ def cli(env):
         zone_date = zone.get('updateDate', None)
         if zone_date is None:
             # The serial is just YYYYMMDD##, and since there is no createDate, just format it like it was one.
-            zone_date = "{}-{}-{}T00:00:00-06:00".format(zone_serial[0:4], zone_serial[4:6], zone_serial[6:8])
+            zone_date = f"{zone_serial[0:4]}-{zone_serial[4:6]}-{zone_serial[6:8]}T00:00:00-06:00"
         table.add_row([
             zone['id'],
             zone['name'],
diff --git a/SoftLayer/CLI/event_log/get.py b/SoftLayer/CLI/event_log/get.py
index d801a60a..92a48170 100644
--- a/SoftLayer/CLI/event_log/get.py
+++ b/SoftLayer/CLI/event_log/get.py
@@ -70,20 +70,13 @@ def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metada
         if metadata:
             metadata_data = log['metaData'].strip("\n\t")
 
-            click.secho("'{0}','{1}','{2}','{3}','{4}','{5}'".format(
-                log['eventName'],
-                label,
-                log['objectName'],
-                utils.clean_time(log['eventCreateDate'], in_format=log_time),
-                user,
-                metadata_data))
+            click.secho(f"'{log['eventName']}','{label}','{log['objectName']}',"
+                        f"'{utils.clean_time(log['eventCreateDate'], in_format=log_time)}',"
+                        f"'{user}','{metadata_data}'")
         else:
-            click.secho("'{0}','{1}','{2}','{3}','{4}'".format(
-                log['eventName'],
-                label,
-                log['objectName'],
-                utils.clean_time(log['eventCreateDate'], in_format=log_time),
-                user))
+            click.secho(f"'{log['eventName']}','{label}','{log['objectName']}',"
+                        f"'{utils.clean_time(log['eventCreateDate'],in_format=log_time)}',"
+                        f"'{user}'")
 
         row_count = row_count + 1
         if row_count >= limit and limit != -1:
diff --git a/SoftLayer/CLI/file/access/list.py b/SoftLayer/CLI/file/access/list.py
index 5f868bb5..b913ee5b 100644
--- a/SoftLayer/CLI/file/access/list.py
+++ b/SoftLayer/CLI/file/access/list.py
@@ -15,8 +15,7 @@
 @click.option('--sortby', help='Column to sort by', default='name')
 @click.option('--columns',
               callback=column_helper.get_formatter(storage_utils.COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in storage_utils.COLUMNS)),
+              help=f"Columns to display. Options: { ', '.join(column.name for column in storage_utils.COLUMNS)}",
               default=','.join(storage_utils.DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, columns, sortby, volume_id):
diff --git a/SoftLayer/CLI/file/detail.py b/SoftLayer/CLI/file/detail.py
index 999acb63..cc486045 100644
--- a/SoftLayer/CLI/file/detail.py
+++ b/SoftLayer/CLI/file/detail.py
@@ -134,7 +134,7 @@ def cli(env, volume_id):
             original_volume_info.add_row(['Original Snapshot Name', file_volume['originalSnapshotName']])
         table.add_row(['Original Volume Properties', original_volume_info])
 
-    notes = '{}'.format(file_volume.get('notes', ''))
+    notes = f"{file_volume.get('notes', '')}"
     table.add_row(['Notes', notes])
 
     env.fout(table)
diff --git a/SoftLayer/CLI/file/duplicate.py b/SoftLayer/CLI/file/duplicate.py
index b074f587..b8b5983b 100644
--- a/SoftLayer/CLI/file/duplicate.py
+++ b/SoftLayer/CLI/file/duplicate.py
@@ -87,8 +87,7 @@ def cli(env, origin_volume_id, origin_snapshot_id, duplicate_size,
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
     else:
diff --git a/SoftLayer/CLI/file/list.py b/SoftLayer/CLI/file/list.py
index 6eb0a094..600fa6cd 100644
--- a/SoftLayer/CLI/file/list.py
+++ b/SoftLayer/CLI/file/list.py
@@ -63,8 +63,7 @@
 @click.option('--sortby', help='Column to sort by', default='username')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, sortby, columns, datacenter, username, storage_type, order):
diff --git a/SoftLayer/CLI/file/modify.py b/SoftLayer/CLI/file/modify.py
index 1ae3537a..244868e4 100644
--- a/SoftLayer/CLI/file/modify.py
+++ b/SoftLayer/CLI/file/modify.py
@@ -50,7 +50,7 @@ def cli(env, volume_id, new_size, new_iops, new_tier):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
     else:
diff --git a/SoftLayer/CLI/file/order.py b/SoftLayer/CLI/file/order.py
index 38cfb46b..876549be 100644
--- a/SoftLayer/CLI/file/order.py
+++ b/SoftLayer/CLI/file/order.py
@@ -62,7 +62,7 @@ def cli(env, storage_type, size, iops, tier,
         hourly_billing_flag = True
 
     if service_offering != 'storage_as_a_service':
-        click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
+        click.secho(f'{service_offering} is a legacy storage offering', fg='red')
         if hourly_billing_flag:
             raise exceptions.CLIAbort(
                 'Hourly billing is only available for the storage_as_a_service service offering'
@@ -111,12 +111,11 @@ def cli(env, storage_type, size, iops, tier,
             raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
         click.echo(
-            '\nYou may run "slcli file volume-list --order {0}" to find this file volume after it '
-            'is ready.'.format(order['placedOrder']['id']))
+            f"\nYou may run \"slcli file volume-list --order {order['placedOrder']['id']}\" to find this file "
+            "volume after it is ready.")
     else:
         click.echo("Order could not be placed! Please verify your options and try again.")
diff --git a/SoftLayer/CLI/file/replication/locations.py b/SoftLayer/CLI/file/replication/locations.py
index 441f72d5..0dbc1704 100644
--- a/SoftLayer/CLI/file/replication/locations.py
+++ b/SoftLayer/CLI/file/replication/locations.py
@@ -25,8 +25,7 @@
 @click.option('--sortby', help='Column to sort by', default='Long Name')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, columns, sortby, volume_id):
diff --git a/SoftLayer/CLI/file/replication/order.py b/SoftLayer/CLI/file/replication/order.py
index 43292d42..14e4ae15 100644
--- a/SoftLayer/CLI/file/replication/order.py
+++ b/SoftLayer/CLI/file/replication/order.py
@@ -47,8 +47,7 @@ def cli(env, volume_id, snapshot_schedule, location, tier):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            utils.lookup(order, 'placedOrder', 'id')))
+        click.echo(f"Order #{utils.lookup(order, 'placedOrder', 'id')} placed successfully!")
         for item in utils.lookup(order, 'placedOrder', 'items'):
             click.echo(" > %s" % item.get('description'))
     else:
diff --git a/SoftLayer/CLI/file/replication/partners.py b/SoftLayer/CLI/file/replication/partners.py
index d7065691..e4eb971d 100644
--- a/SoftLayer/CLI/file/replication/partners.py
+++ b/SoftLayer/CLI/file/replication/partners.py
@@ -17,8 +17,7 @@
 @click.option('--sortby', help='Column to sort by', default='Username')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, columns, sortby, volume_id):
diff --git a/SoftLayer/CLI/file/snapshot/get_notify_status.py b/SoftLayer/CLI/file/snapshot/get_notify_status.py
index f04e8857..af0aff31 100644
--- a/SoftLayer/CLI/file/snapshot/get_notify_status.py
+++ b/SoftLayer/CLI/file/snapshot/get_notify_status.py
@@ -16,6 +16,6 @@ def cli(env, volume_id):
     enabled = file_manager.get_volume_snapshot_notification_status(volume_id)
 
     if enabled == 0:
-        click.echo("Disabled: Snapshots space usage threshold is disabled for volume {}".format(volume_id))
+        click.echo(f"Disabled: Snapshots space usage threshold is disabled for volume {volume_id}")
     else:
-        click.echo("Enabled: Snapshots space usage threshold is enabled for volume {}".format(volume_id))
+        click.echo(f"Enabled: Snapshots space usage threshold is enabled for volume {volume_id}")
diff --git a/SoftLayer/CLI/file/snapshot/list.py b/SoftLayer/CLI/file/snapshot/list.py
index 872a4668..9663a456 100644
--- a/SoftLayer/CLI/file/snapshot/list.py
+++ b/SoftLayer/CLI/file/snapshot/list.py
@@ -31,8 +31,7 @@
               default='created')
 @click.option('--columns',
               callback=column_helper.get_formatter(COLUMNS),
-              help='Columns to display. Options: {0}'.format(
-                  ', '.join(column.name for column in COLUMNS)),
+              help=f"Columns to display. Options: {', '.join(column.name for column in COLUMNS)}",
               default=','.join(DEFAULT_COLUMNS))
 @environment.pass_env
 def cli(env, volume_id, sortby, columns):
diff --git a/SoftLayer/CLI/file/snapshot/order.py b/SoftLayer/CLI/file/snapshot/order.py
index b61d0889..f03a3cd3 100644
--- a/SoftLayer/CLI/file/snapshot/order.py
+++ b/SoftLayer/CLI/file/snapshot/order.py
@@ -42,8 +42,7 @@ def cli(env, volume_id, capacity, tier, upgrade):
         raise exceptions.ArgumentError(str(ex))
 
     if 'placedOrder' in order.keys():
-        click.echo("Order #{0} placed successfully!".format(
-            order['placedOrder']['id']))
+        click.echo(f"Order #{order['placedOrder']['id']} placed successfully!")
         for item in order['placedOrder']['items']:
             click.echo(" > %s" % item['description'])
         if 'status' in order['placedOrder'].keys():
diff --git a/SoftLayer/CLI/formatting.py b/SoftLayer/CLI/formatting.py
index 38cafb31..17731fe2 100644
--- a/SoftLayer/CLI/formatting.py
+++ b/SoftLayer/CLI/formatting.py
@@ -144,7 +144,7 @@ def convert_sizes(value, unit='GB', round_result=False):
 
     if round_result:
         value = round(value / 5) * 5
-    return "{:.2f} {}".format(value, units[unit_index])
+    return f"{value:.2f} {units[unit_index]}"
 
 
 def sum_sizes(size1, size2):
@@ -176,7 +176,7 @@ def sum_sizes(size1, size2):
         total_value /= 1024
         total_unit = units[units.index(total_unit) + 1]
 
-    return "{:.2f} {}".format(total_value, total_unit)
+    return f"{total_value:.2f} {total_unit}"
 
 
 def blank():


Test patch:
diff --git a/tests/CLI/modules/block_tests.py b/tests/CLI/modules/block_tests.py
index e6237027..894acd94 100644
--- a/tests/CLI/modules/block_tests.py
+++ b/tests/CLI/modules/block_tests.py
@@ -231,7 +231,7 @@ def test_volume_order_performance(self, order_mock):
                          ' > Performance Storage\n > Block Storage\n'
                          ' > 0.25 IOPS per GB\n > 20 GB Storage Space\n'
                          ' > 10 GB Storage Space (Snapshot Space)\n'
-                         '\nYou may run "slcli block volume-list --order 478" to find this block volume '
+                         '\nYou may run \'slcli block volume-list --order 478\' to find this block volume '
                          'after it is ready.\n')
 
     def test_volume_order_endurance_tier_not_given(self):
@@ -266,7 +266,7 @@ def test_volume_order_endurance(self, order_mock):
                          ' > Endurance Storage\n > Block Storage\n'
                          ' > 0.25 IOPS per GB\n > 20 GB Storage Space\n'
                          ' > 10 GB Storage Space (Snapshot Space)\n'
-                         '\nYou may run "slcli block volume-list --order 478" to find this block volume '
+                         '\nYou may run \'slcli block volume-list --order 478\' to find this block volume '
                          'after it is ready.\n')
 
     @mock.patch('SoftLayer.BlockStorageManager.order_block_volume')
@@ -317,7 +317,7 @@ def test_volume_order_hourly_billing(self, order_mock):
                          ' > Block Storage\n'
                          ' > 20 GB Storage Space\n'
                          ' > 200 IOPS\n'
-                         '\nYou may run "slcli block volume-list --order 10983647" to find this block volume '
+                         '\nYou may run \'slcli block volume-list --order 10983647\' to find this block volume '
                          'after it is ready.\n')
 
     @mock.patch('SoftLayer.BlockStorageManager.order_block_volume')