Skip to content

Commit 28715a7

Browse files
daniellebrownjreback
authored andcommitted
f string in io.common (#30022)
1 parent dafbee7 commit 28715a7

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pandas/io/common.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def get_filepath_or_buffer(
246246
return _expand_user(filepath_or_buffer), None, compression, False
247247

248248
if not is_file_like(filepath_or_buffer):
249-
msg = "Invalid file path or buffer object type: {_type}"
250-
raise ValueError(msg.format(_type=type(filepath_or_buffer)))
249+
msg = f"Invalid file path or buffer object type: {type(filepath_or_buffer)}"
250+
raise ValueError(msg)
251251

252252
return filepath_or_buffer, None, compression, False
253253

@@ -355,9 +355,9 @@ def _infer_compression(
355355
if compression in _compression_to_extension:
356356
return compression
357357

358-
msg = "Unrecognized compression type: {}".format(compression)
358+
msg = f"Unrecognized compression type: {compression}"
359359
valid = ["infer", None] + sorted(_compression_to_extension)
360-
msg += "\nValid compression types are {}".format(valid)
360+
msg += f"\nValid compression types are {valid}"
361361
raise ValueError(msg)
362362

363363

@@ -454,13 +454,11 @@ def _get_handle(
454454
if len(zip_names) == 1:
455455
f = zf.open(zip_names.pop())
456456
elif len(zip_names) == 0:
457-
raise ValueError(
458-
"Zero files found in ZIP file {}".format(path_or_buf)
459-
)
457+
raise ValueError(f"Zero files found in ZIP file {path_or_buf}")
460458
else:
461459
raise ValueError(
462460
"Multiple files found in ZIP file."
463-
" Only one file per ZIP: {}".format(zip_names)
461+
f" Only one file per ZIP: {zip_names}"
464462
)
465463

466464
# XZ Compression
@@ -469,7 +467,7 @@ def _get_handle(
469467

470468
# Unrecognized Compression
471469
else:
472-
msg = "Unrecognized compression type: {}".format(compression)
470+
msg = f"Unrecognized compression type: {compression}"
473471
raise ValueError(msg)
474472

475473
handles.append(f)

0 commit comments

Comments
 (0)