Skip to content

f string in io.common #30022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def get_filepath_or_buffer(
return _expand_user(filepath_or_buffer), None, compression, False

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

return filepath_or_buffer, None, compression, False

Expand Down Expand Up @@ -355,9 +355,9 @@ def _infer_compression(
if compression in _compression_to_extension:
return compression

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


Expand Down Expand Up @@ -454,13 +454,11 @@ def _get_handle(
if len(zip_names) == 1:
f = zf.open(zip_names.pop())
elif len(zip_names) == 0:
raise ValueError(
"Zero files found in ZIP file {}".format(path_or_buf)
)
raise ValueError(f"Zero files found in ZIP file {path_or_buf}")
else:
raise ValueError(
"Multiple files found in ZIP file."
" Only one file per ZIP: {}".format(zip_names)
f" Only one file per ZIP: {zip_names}"
)

# XZ Compression
Expand All @@ -469,7 +467,7 @@ def _get_handle(

# Unrecognized Compression
else:
msg = "Unrecognized compression type: {}".format(compression)
msg = f"Unrecognized compression type: {compression}"
raise ValueError(msg)

handles.append(f)
Expand Down