From 9b6657d56507f8dcec2b83e36e178c44e236dfb1 Mon Sep 17 00:00:00 2001 From: Danielle Date: Tue, 3 Dec 2019 15:24:03 -0800 Subject: [PATCH 1/2] f string in io.common --- pandas/io/common.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index c0eddb679c6f8..6af80af27143b 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -249,8 +249,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 @@ -358,9 +358,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) @@ -458,12 +458,12 @@ def _get_handle( f = zf.open(zip_names.pop()) elif len(zip_names) == 0: raise ValueError( - "Zero files found in ZIP file {}".format(path_or_buf) + 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"Multiple files found in ZIP file." + " Only one file per ZIP: {zip_names}" ) # XZ Compression @@ -472,7 +472,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) From e2dbc5dc7adcf04dc3a95d4dbaf18121c426fd46 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Wed, 11 Dec 2019 09:47:45 +0000 Subject: [PATCH 2/2] fixup --- pandas/io/common.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index bfd10a213454f..a01011cd7d4e4 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -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( - f"Zero files found in ZIP file {path_or_buf}" - ) + raise ValueError(f"Zero files found in ZIP file {path_or_buf}") else: raise ValueError( - f"Multiple files found in ZIP file." - " Only one file per ZIP: {zip_names}" + "Multiple files found in ZIP file." + f" Only one file per ZIP: {zip_names}" ) # XZ Compression