Skip to content

Commit d8c6cce

Browse files
committed
Run ruff check --fix
1 parent ff6417d commit d8c6cce

File tree

3 files changed

+30
-39
lines changed

3 files changed

+30
-39
lines changed

awscli/customizations/gamelift/uploadbuild.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ def _run_main(self, args, parsed_globals):
6767
# Validate a build directory
6868
if not validate_directory(args.build_root):
6969
sys.stderr.write(
70-
'Fail to upload %s. '
70+
f'Fail to upload {args.build_root}. '
7171
'The build root directory is empty or does not exist.\n'
72-
% (args.build_root)
7372
)
7473

7574
return 255
@@ -111,7 +110,7 @@ def _run_main(self, args, parsed_globals):
111110
s3_transfer_mgr = S3Transfer(s3_client)
112111

113112
try:
114-
fd, temporary_zipfile = tempfile.mkstemp('%s.zip' % build_id)
113+
fd, temporary_zipfile = tempfile.mkstemp(f'{build_id}.zip')
115114
zip_directory(temporary_zipfile, args.build_root)
116115
s3_transfer_mgr.upload_file(
117116
temporary_zipfile, bucket, key,
@@ -125,8 +124,8 @@ def _run_main(self, args, parsed_globals):
125124
os.remove(temporary_zipfile)
126125

127126
sys.stdout.write(
128-
'Successfully uploaded %s to AWS GameLift\n'
129-
'Build ID: %s\n' % (args.build_root, build_id))
127+
f'Successfully uploaded {args.build_root} to AWS GameLift\n'
128+
f'Build ID: {build_id}\n')
130129

131130
return 0
132131

@@ -159,7 +158,7 @@ def validate_directory(source_root):
159158

160159
# TODO: Remove this class once available to CLI from s3transfer
161160
# docstring.
162-
class ProgressPercentage(object):
161+
class ProgressPercentage:
163162
def __init__(self, filename, label=None):
164163
self._filename = filename
165164
self._label = label
@@ -175,9 +174,6 @@ def __call__(self, bytes_amount):
175174
if self._size > 0:
176175
percentage = (self._seen_so_far / self._size) * 100
177176
sys.stdout.write(
178-
"\r%s %s / %s (%.2f%%)" % (
179-
self._label, human_readable_size(self._seen_so_far),
180-
human_readable_size(self._size), percentage
181-
)
177+
f"\r{self._label} {human_readable_size(self._seen_so_far)} / {human_readable_size(self._size)} ({percentage:.2f}%)"
182178
)
183179
sys.stdout.flush()

tests/functional/gamelift/test_upload_build.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ class TestUploadBuild(BaseAWSCommandParamsTest):
1919
prefix = 'gamelift upload-build'
2020

2121
def setUp(self):
22-
super(TestUploadBuild, self).setUp()
22+
super().setUp()
2323
self.files = FileCreator()
2424

2525
def tearDown(self):
26-
super(TestUploadBuild, self).tearDown()
26+
super().tearDown()
2727
self.files.remove_all()
2828

2929
def test_upload_build(self):
3030
self.files.create_file('tmpfile', 'Some contents')
3131
cmdline = self.prefix
3232
cmdline += ' --name mybuild --build-version myversion'
33-
cmdline += ' --build-root %s' % self.files.rootdir
33+
cmdline += f' --build-root {self.files.rootdir}'
3434

3535
self.parsed_responses = [
3636
{'Build': {'BuildId': 'myid'}},
@@ -69,15 +69,15 @@ def test_upload_build(self):
6969

7070
# Check the output of the command.
7171
self.assertIn(
72-
'Successfully uploaded %s to AWS GameLift' % self.files.rootdir,
72+
f'Successfully uploaded {self.files.rootdir} to AWS GameLift',
7373
stdout)
7474
self.assertIn('Build ID: myid', stdout)
7575

7676
def test_upload_build_with_operating_system_param(self):
7777
self.files.create_file('tmpfile', 'Some contents')
7878
cmdline = self.prefix
7979
cmdline += ' --name mybuild --build-version myversion'
80-
cmdline += ' --build-root %s' % self.files.rootdir
80+
cmdline += f' --build-root {self.files.rootdir}'
8181
cmdline += ' --operating-system WINDOWS_2012'
8282

8383
self.parsed_responses = [
@@ -118,14 +118,14 @@ def test_upload_build_with_operating_system_param(self):
118118

119119
# Check the output of the command.
120120
self.assertIn(
121-
'Successfully uploaded %s to AWS GameLift' % self.files.rootdir,
121+
f'Successfully uploaded {self.files.rootdir} to AWS GameLift',
122122
stdout)
123123
self.assertIn('Build ID: myid', stdout)
124124

125125
def test_upload_build_with_empty_directory(self):
126126
cmdline = self.prefix
127127
cmdline += ' --name mybuild --build-version myversion'
128-
cmdline += ' --build-root %s' % self.files.rootdir
128+
cmdline += f' --build-root {self.files.rootdir}'
129129

130130
self.parsed_responses = [
131131
{'Build': {'BuildId': 'myid'}},
@@ -142,17 +142,16 @@ def test_upload_build_with_empty_directory(self):
142142
stdout, stderr, rc = self.run_cmd(cmdline, expected_rc=255)
143143

144144
self.assertIn(
145-
'Fail to upload %s. '
146-
'The build root directory is empty or does not exist.\n'
147-
% self.files.rootdir,
145+
f'Fail to upload {self.files.rootdir}. '
146+
'The build root directory is empty or does not exist.\n',
148147
stderr)
149148

150149
def test_upload_build_with_nonexistent_directory(self):
151150
dir_not_exist = os.path.join(self.files.rootdir, 'does_not_exist')
152151

153152
cmdline = self.prefix
154153
cmdline += ' --name mybuild --build-version myversion'
155-
cmdline += ' --build-root %s' % dir_not_exist
154+
cmdline += f' --build-root {dir_not_exist}'
156155

157156
self.parsed_responses = [
158157
{'Build': {'BuildId': 'myid'}},
@@ -169,15 +168,14 @@ def test_upload_build_with_nonexistent_directory(self):
169168
stdout, stderr, rc = self.run_cmd(cmdline, expected_rc=255)
170169

171170
self.assertIn(
172-
'Fail to upload %s. '
173-
'The build root directory is empty or does not exist.\n'
174-
% dir_not_exist,
171+
f'Fail to upload {dir_not_exist}. '
172+
'The build root directory is empty or does not exist.\n',
175173
stderr)
176174

177175
def test_upload_build_with_nonprovided_directory(self):
178176
cmdline = self.prefix
179177
cmdline += ' --name mybuild --build-version myversion'
180-
cmdline += ' --build-root %s' % '""'
178+
cmdline += ' --build-root {}'.format('""')
181179

182180
self.parsed_responses = [
183181
{'Build': {'BuildId': 'myid'}},
@@ -194,16 +192,15 @@ def test_upload_build_with_nonprovided_directory(self):
194192
stdout, stderr, rc = self.run_cmd(cmdline, expected_rc=255)
195193

196194
self.assertIn(
197-
'Fail to upload %s. '
198-
'The build root directory is empty or does not exist.\n'
199-
% '""',
195+
'Fail to upload {}. '
196+
'The build root directory is empty or does not exist.\n'.format('""'),
200197
stderr)
201198

202199
def test_upload_build_with_server_sdk_version_param(self):
203200
self.files.create_file('tmpfile', 'Some contents')
204201
cmdline = self.prefix
205202
cmdline += ' --name mybuild --build-version myversion'
206-
cmdline += ' --build-root %s' % self.files.rootdir
203+
cmdline += f' --build-root {self.files.rootdir}'
207204
cmdline += ' --server-sdk-version 4.0.2'
208205

209206
self.parsed_responses = [
@@ -244,7 +241,7 @@ def test_upload_build_with_server_sdk_version_param(self):
244241

245242
# Check the output of the command.
246243
self.assertIn(
247-
'Successfully uploaded %s to AWS GameLift' % self.files.rootdir,
244+
f'Successfully uploaded {self.files.rootdir} to AWS GameLift',
248245
stdout)
249246
self.assertIn('Build ID: myid', stdout)
250247

@@ -258,10 +255,10 @@ def test_upload_build_with_tags_param(self):
258255

259256
cmdline = self.prefix
260257
cmdline += ' --name mybuild --build-version myversion'
261-
cmdline += ' --build-root %s' % self.files.rootdir
258+
cmdline += f' --build-root {self.files.rootdir}'
262259
cmdline += ' --tags'
263260
for tag in expected_tags:
264-
cmdline += ' %s=%s' % (tag['Key'], tag['Value'])
261+
cmdline += ' {}={}'.format(tag['Key'], tag['Value'])
265262

266263
self.parsed_responses = [
267264
{'Build': {'BuildId': 'myid'}},
@@ -301,6 +298,6 @@ def test_upload_build_with_tags_param(self):
301298

302299
# Check the output of the command.
303300
self.assertIn(
304-
'Successfully uploaded %s to AWS GameLift' % self.files.rootdir,
301+
f'Successfully uploaded {self.files.rootdir} to AWS GameLift',
305302
stdout)
306303
self.assertIn('Build ID: myid', stdout)

tests/unit/customizations/gamelift/test_uploadbuild.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,8 @@ def test_error_message_when_directory_is_empty(self):
147147
self.cmd(self.args, self.global_args)
148148
self.assertEqual(
149149
mock_stderr.getvalue(),
150-
'Fail to upload %s. '
150+
f'Fail to upload {self.build_root}. '
151151
'The build root directory is empty or does not exist.\n'
152-
% (self.build_root)
153152
)
154153

155154
def test_error_message_when_directory_is_not_provided(self):
@@ -163,8 +162,8 @@ def test_error_message_when_directory_is_not_provided(self):
163162
self.cmd(self.args, self.global_args)
164163
self.assertEqual(
165164
mock_stderr.getvalue(),
166-
'Fail to upload %s. '
167-
'The build root directory is empty or does not exist.\n' % ('')
165+
'Fail to upload {}. '
166+
'The build root directory is empty or does not exist.\n'.format('')
168167
)
169168

170169
def test_error_message_when_directory_does_not_exist(self):
@@ -180,9 +179,8 @@ def test_error_message_when_directory_does_not_exist(self):
180179
self.cmd(self.args, self.global_args)
181180
self.assertEqual(
182181
mock_stderr.getvalue(),
183-
'Fail to upload %s. '
182+
f'Fail to upload {dir_not_exist}. '
184183
'The build root directory is empty or does not exist.\n'
185-
% (dir_not_exist)
186184
)
187185

188186
def test_temporary_file_does_exist_when_fails(self):

0 commit comments

Comments
 (0)