From 36ab91851e01bf4a32cb88a635a483c5443c2b63 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Tue, 26 Nov 2019 22:15:22 +0200 Subject: [PATCH] F-strings --- pandas/io/msgpack/_packer.pyx | 2 +- pandas/io/msgpack/_unpacker.pyx | 7 +++---- pandas/io/sas/sas.pyx | 15 +++++---------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pandas/io/msgpack/_packer.pyx b/pandas/io/msgpack/_packer.pyx index 7c7c8f7b61e60..5c0499b489110 100644 --- a/pandas/io/msgpack/_packer.pyx +++ b/pandas/io/msgpack/_packer.pyx @@ -234,7 +234,7 @@ cdef class Packer: default_used = 1 continue else: - raise TypeError("can't serialize {thing!r}".format(thing=o)) + raise TypeError(f"can't serialize {repr(o)}") break return ret diff --git a/pandas/io/msgpack/_unpacker.pyx b/pandas/io/msgpack/_unpacker.pyx index cf9b2c7c04d42..f1817f29bd42a 100644 --- a/pandas/io/msgpack/_unpacker.pyx +++ b/pandas/io/msgpack/_unpacker.pyx @@ -99,7 +99,7 @@ cdef inline init_ctx(unpack_context *ctx, def default_read_extended_type(typecode, data): raise NotImplementedError("Cannot decode extended type " - "with typecode={code}".format(code=typecode)) + f"with typecode={typecode}") def unpackb(object packed, object object_hook=None, object list_hook=None, @@ -159,7 +159,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None, return obj else: PyBuffer_Release(&view) - raise UnpackValueError("Unpack failed: error = {ret}".format(ret=ret)) + raise UnpackValueError(f"Unpack failed: error = {ret}") def unpack(object stream, object object_hook=None, object list_hook=None, @@ -430,8 +430,7 @@ cdef class Unpacker: else: raise OutOfData("No more data to unpack.") else: - raise ValueError("Unpack failed: error = {ret}" - .format(ret=ret)) + raise ValueError(f"Unpack failed: error = {ret}") def read_bytes(self, Py_ssize_t nbytes): """Read a specified number of raw bytes from the stream""" diff --git a/pandas/io/sas/sas.pyx b/pandas/io/sas/sas.pyx index 6378198225516..bb5bce96bc64b 100644 --- a/pandas/io/sas/sas.pyx +++ b/pandas/io/sas/sas.pyx @@ -105,13 +105,11 @@ cdef const uint8_t[:] rle_decompress(int result_length, result[rpos] = 0x00 rpos += 1 else: - raise ValueError("unknown control byte: {byte}" - .format(byte=control_byte)) + raise ValueError(f"unknown control byte: {control_byte}") # In py37 cython/clang sees `len(outbuff)` as size_t and not Py_ssize_t if len(result) != result_length: - raise ValueError("RLE: {got} != {expect}".format(got=len(result), - expect=result_length)) + raise ValueError(f"RLE: {len(result)} != {result_length}") return np.asarray(result) @@ -194,8 +192,7 @@ cdef const uint8_t[:] rdc_decompress(int result_length, # In py37 cython/clang sees `len(outbuff)` as size_t and not Py_ssize_t if len(outbuff) != result_length: - raise ValueError("RDC: {got} != {expect}\n" - .format(got=len(outbuff), expect=result_length)) + raise ValueError(f"RDC: {len(outbuff)} != {result_length}\n") return np.asarray(outbuff) @@ -271,8 +268,7 @@ cdef class Parser: self.column_types[j] = column_type_string else: raise ValueError("unknown column type: " - "{typ}" - .format(typ=self.parser.columns[j].ctype)) + f"{self.parser.columns[j].ctype}") # compression if parser.compression == const.rle_compression: @@ -392,8 +388,7 @@ cdef class Parser: return True return False else: - raise ValueError("unknown page type: {typ}" - .format(typ=self.current_page_type)) + raise ValueError(f"unknown page type: {self.current_page_type}") cdef void process_byte_array_with_data(self, int offset, int length):