Skip to content

Commit

Permalink
F-strings (pandas-dev#29870)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaharNaveh authored and proost committed Dec 19, 2019
1 parent 3840874 commit c1ddb23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pandas/io/msgpack/_packer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions pandas/io/msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"""
Expand Down
15 changes: 5 additions & 10 deletions pandas/io/sas/sas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Py_ssize_t>len(result) != <Py_ssize_t>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)

Expand Down Expand Up @@ -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 <Py_ssize_t>len(outbuff) != <Py_ssize_t>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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit c1ddb23

Please sign in to comment.