Skip to content

Commit

Permalink
Address exception string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt committed Jan 26, 2022
1 parent 6d22fb8 commit bc435e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
5 changes: 1 addition & 4 deletions s3transfer/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ def __init__(
self._validate_attrs_are_nonzero()

def _validate_attrs_are_nonzero(self):
for (
attr,
attr_val,
) in self.__dict__.items():
for attr, attr_val in self.__dict__.items():
if attr_val is not None and attr_val <= 0:
raise ValueError(
'Provided parameter %s of value %s must be greater than '
Expand Down
8 changes: 4 additions & 4 deletions s3transfer/processpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ def _start(self):
def _validate_all_known_args(self, provided):
for kwarg in provided:
if kwarg not in ALLOWED_DOWNLOAD_ARGS:
download_args = ', '.join(ALLOWED_DOWNLOAD_ARGS)
raise ValueError(
"Invalid extra_args key '%s', "
"must be one of: %s"
% (kwarg, ', '.join(ALLOWED_DOWNLOAD_ARGS))
f"Invalid extra_args key '{kwarg}', "
f"must be one of: {download_args}"
)

def _get_transfer_future(self, transfer_id, call_args):
Expand Down Expand Up @@ -830,7 +830,7 @@ def _get_size(self, download_file_request):
expected_size = self._client.head_object(
Bucket=download_file_request.bucket,
Key=download_file_request.key,
**download_file_request.extra_args
**download_file_request.extra_args,
)['ContentLength']
return expected_size

Expand Down
4 changes: 1 addition & 3 deletions s3transfer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,7 @@ def disable_callback(self):
def seek(self, where, whence=0):
if whence not in (0, 1, 2):
# Mimic io's error for invalid whence values
raise ValueError(
"invalid whence (%s, should be 0, 1 or 2)" % whence
)
raise ValueError(f"invalid whence ({whence}, should be 0, 1 or 2)")

# Recalculate where based on chunk attributes so seek from file
# start (whence=0) is always used
Expand Down
13 changes: 2 additions & 11 deletions scripts/performance/benchmark
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,8 @@ def run_benchmark(pid, output_file, data_interval):

# Save all of the data into a CSV file.
f.write(
','.join(
str(val)
for val in [
current_time,
memory_used,
cpu_percent,
sent_rate,
recv_rate,
]
)
+ '\n'
f"{current_time},{memory_used},{cpu_percent},"
f"{sent_rate},{recv_rate}\n"
)
f.flush()
return 0
Expand Down

0 comments on commit bc435e6

Please sign in to comment.