Skip to content

Commit 4a32a93

Browse files
committed
lint and format
1 parent fd4bfe8 commit 4a32a93

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

awscli/customizations/s3/results.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ class ResultPrinter(BaseResultHandler):
316316
SRC_TRANSFER_LOCATION_FORMAT = '{src}'
317317

318318
def __init__(
319-
self, result_recorder, out_file=None, error_file=None, frequency=0, oneline=True
319+
self,
320+
result_recorder,
321+
out_file=None,
322+
error_file=None,
323+
frequency=0,
324+
oneline=True,
320325
):
321326
"""Prints status of ongoing transfer
322327
@@ -356,21 +361,20 @@ def __init__(
356361

357362
def __call__(self, result):
358363
"""Print the progress of the ongoing transfer based on a result"""
359-
result_handler = self._result_handler_map.get(type(result), self._print_noop)
360-
if type(result) is ProgressResult:
364+
result_handler = self._result_handler_map.get(
365+
type(result), self._print_noop
366+
)
367+
if type(result) is ProgressResult:
361368
result_handler = self._override_progress_result_handler(
362369
result, result_handler
363370
)
364371
result_handler(result=result)
365372

366373
def _override_progress_result_handler(self, result, result_handler):
367-
if (
368-
type(result) in [ProgressResult]
369-
and (
370-
self._first
371-
or (self._frequency == 0)
372-
or (time.time() - self._now >= self._frequency)
373-
)
374+
if type(result) in [ProgressResult] and (
375+
self._first
376+
or (self._frequency == 0)
377+
or (time.time() - self._now >= self._frequency)
374378
):
375379
self._now = time.time()
376380
self._first = False

awscli/customizations/s3/subcommands.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,7 @@
543543
'name': 'progress-multiline',
544544
'dest': 'progress_multiline',
545545
'action': 'store_true',
546-
'help_text': (
547-
'Show progress on multiple lines.'
548-
),
546+
'help_text': ('Show progress on multiple lines.'),
549547
}
550548

551549

@@ -738,7 +736,7 @@ class ListCommand(S3Command):
738736
]
739737

740738
def _run_main(self, parsed_args, parsed_globals):
741-
super(ListCommand, self)._run_main(parsed_args, parsed_globals)
739+
super()._run_main(parsed_args, parsed_globals)
742740
self._empty_result = False
743741
self._at_first_page = True
744742
self._size_accumulator = 0
@@ -881,7 +879,7 @@ def _make_last_mod_str(self, last_mod):
881879
str(last_mod.minute).zfill(2),
882880
str(last_mod.second).zfill(2),
883881
)
884-
last_mod_str = "%s-%s-%s %s:%s:%s" % last_mod_tup
882+
last_mod_str = "%s-%s-%s %s:%s:%s" % last_mod_tup # noqa: UP031
885883
return last_mod_str.ljust(19, ' ')
886884

887885
def _make_size_str(self, size):
@@ -923,7 +921,7 @@ class WebsiteCommand(S3Command):
923921
]
924922

925923
def _run_main(self, parsed_args, parsed_globals):
926-
super(WebsiteCommand, self)._run_main(parsed_args, parsed_globals)
924+
super()._run_main(parsed_args, parsed_globals)
927925
bucket = self._get_bucket_name(parsed_args.paths[0])
928926
website_configuration = self._build_website_configuration(parsed_args)
929927
self.client.put_bucket_website(
@@ -981,7 +979,7 @@ class PresignCommand(S3Command):
981979
]
982980

983981
def _run_main(self, parsed_args, parsed_globals):
984-
super(PresignCommand, self)._run_main(parsed_args, parsed_globals)
982+
super()._run_main(parsed_args, parsed_globals)
985983
path = parsed_args.path
986984
if path.startswith('s3://'):
987985
path = path[5:]
@@ -998,7 +996,7 @@ def _run_main(self, parsed_args, parsed_globals):
998996

999997
class S3TransferCommand(S3Command):
1000998
def _run_main(self, parsed_args, parsed_globals):
1001-
super(S3TransferCommand, self)._run_main(parsed_args, parsed_globals)
999+
super()._run_main(parsed_args, parsed_globals)
10021000
register_feature_id('S3_TRANSFER')
10031001
self._convert_path_args(parsed_args)
10041002
params = self._get_params(parsed_args, parsed_globals, self._session)
@@ -1161,11 +1159,11 @@ class MbCommand(S3Command):
11611159
ARG_TABLE = [{'name': 'path', 'positional_arg': True, 'synopsis': USAGE}]
11621160

11631161
def _run_main(self, parsed_args, parsed_globals):
1164-
super(MbCommand, self)._run_main(parsed_args, parsed_globals)
1162+
super()._run_main(parsed_args, parsed_globals)
11651163

11661164
if not parsed_args.path.startswith('s3://'):
11671165
raise ParamValidationError(
1168-
"%s\nError: Invalid argument type" % self.USAGE
1166+
f"{self.USAGE}\nError: Invalid argument type"
11691167
)
11701168
bucket, _ = split_s3_bucket_key(parsed_args.path)
11711169

@@ -1182,11 +1180,11 @@ def _run_main(self, parsed_args, parsed_globals):
11821180
# TODO: Consolidate how we handle return codes and errors
11831181
try:
11841182
self.client.create_bucket(**params)
1185-
uni_print("make_bucket: %s\n" % bucket)
1183+
uni_print(f"make_bucket: {bucket}\n")
11861184
return 0
11871185
except Exception as e:
11881186
uni_print(
1189-
"make_bucket failed: %s %s\n" % (parsed_args.path, e),
1187+
f"make_bucket failed: {parsed_args.path} {e}\n",
11901188
sys.stderr,
11911189
)
11921190
return 1
@@ -1208,30 +1206,30 @@ class RbCommand(S3Command):
12081206
]
12091207

12101208
def _run_main(self, parsed_args, parsed_globals):
1211-
super(RbCommand, self)._run_main(parsed_args, parsed_globals)
1209+
super()._run_main(parsed_args, parsed_globals)
12121210

12131211
if not parsed_args.path.startswith('s3://'):
12141212
raise ParamValidationError(
1215-
"%s\nError: Invalid argument type" % self.USAGE
1213+
f"{self.USAGE}\nError: Invalid argument type"
12161214
)
12171215
bucket, key = split_s3_bucket_key(parsed_args.path)
12181216

12191217
if key:
12201218
raise ParamValidationError(
12211219
'Please specify a valid bucket name only. '
1222-
'E.g. s3://%s' % bucket
1220+
f'E.g. s3://{bucket}'
12231221
)
12241222

12251223
if parsed_args.force:
12261224
self._force(parsed_args.path, parsed_globals)
12271225

12281226
try:
12291227
self.client.delete_bucket(Bucket=bucket)
1230-
uni_print("remove_bucket: %s\n" % bucket)
1228+
uni_print(f"remove_bucket: {bucket}\n")
12311229
return 0
12321230
except Exception as e:
12331231
uni_print(
1234-
"remove_bucket failed: %s %s\n" % (parsed_args.path, e),
1232+
f"remove_bucket failed: {parsed_args.path} {e}\n",
12351233
sys.stderr,
12361234
)
12371235
return 1
@@ -1637,7 +1635,7 @@ def _validate_path_args(self):
16371635
if 'locals3' == params['paths_type'] and not params['is_stream']:
16381636
if not os.path.exists(params['src']):
16391637
raise RuntimeError(
1640-
'The user-provided path %s does not exist.' % params['src']
1638+
f'The user-provided path {params['src']} does not exist.'
16411639
)
16421640
# If the operation is downloading to a directory that does not exist,
16431641
# create the directories so no warnings are thrown during the syncing
@@ -1764,7 +1762,7 @@ def check_path_type(self, paths):
17641762
'locallocal': [],
17651763
}
17661764
paths_type = ''
1767-
usage = "usage: aws s3 %s %s" % (self.cmd, self.usage)
1765+
usage = f"usage: aws s3 {self.cmd} {self.usage}"
17681766
for i in range(len(paths)):
17691767
if paths[i].startswith('s3://'):
17701768
paths_type = paths_type + 's3'
@@ -1774,7 +1772,7 @@ def check_path_type(self, paths):
17741772
self.parameters['paths_type'] = paths_type
17751773
else:
17761774
raise ParamValidationError(
1777-
"%s\nError: Invalid argument type" % usage
1775+
f"{usage}\nError: Invalid argument type"
17781776
)
17791777

17801778
def add_region(self, parsed_globals):
@@ -1814,14 +1812,14 @@ def _validate_sse_c_arg(self, sse_c_type='sse_c'):
18141812
if self.parameters.get(sse_c_type):
18151813
if not self.parameters.get(sse_c_key_type):
18161814
raise ParamValidationError(
1817-
'If %s is specified, %s must be specified '
1818-
'as well.' % (sse_c_type_param, sse_c_key_type_param)
1815+
f'If {sse_c_type_param} is specified, {sse_c_key_type_param} must be specified '
1816+
'as well.'
18191817
)
18201818
if self.parameters.get(sse_c_key_type):
18211819
if not self.parameters.get(sse_c_type):
18221820
raise ParamValidationError(
1823-
'If %s is specified, %s must be specified '
1824-
'as well.' % (sse_c_key_type_param, sse_c_type_param)
1821+
f'If {sse_c_key_type_param} is specified, {sse_c_type_param} must be specified '
1822+
'as well.'
18251823
)
18261824

18271825
def _validate_sse_c_copy_source_for_paths(self):

0 commit comments

Comments
 (0)