-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: str.format -> f-strings for io/sas
#30409
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,7 +169,7 @@ def _get_properties(self): | |
if buf in const.encoding_names: | ||
self.file_encoding = const.encoding_names[buf] | ||
else: | ||
self.file_encoding = "unknown (code={name!s})".format(name=buf) | ||
self.file_encoding = f"unknown (code={str(buf)})" | ||
|
||
# Get platform information | ||
buf = self._read_bytes(const.platform_offset, const.platform_length) | ||
|
@@ -293,8 +293,8 @@ def _read_bytes(self, offset, length): | |
buf = self._path_or_buf.read(length) | ||
if len(buf) < length: | ||
self.close() | ||
msg = "Unable to read {:d} bytes from file position {:d}." | ||
raise ValueError(msg.format(length, offset)) | ||
msg = f"Unable to read {length:d} bytes from file position {offset:d}." | ||
raise ValueError(msg) | ||
return buf | ||
else: | ||
if offset + length > len(self._cached_page): | ||
|
@@ -457,12 +457,9 @@ def _process_columnsize_subheader(self, offset, length): | |
self.column_count = self._read_int(offset, int_len) | ||
if self.col_count_p1 + self.col_count_p2 != self.column_count: | ||
print( | ||
"Warning: column count mismatch ({p1} + {p2} != " | ||
"{column_count})\n".format( | ||
p1=self.col_count_p1, | ||
p2=self.col_count_p2, | ||
column_count=self.column_count, | ||
) | ||
f"Warning: column count mismatch ({self.col_count_p1} + " | ||
f"{self.col_count_p2} != " | ||
f"{self.column_count})\n" | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for follow-up, this probably should use warnings rather than print |
||
|
||
# Unknown purpose | ||
|
@@ -672,8 +669,12 @@ def _read_next_page(self): | |
return True | ||
elif len(self._cached_page) != self._page_length: | ||
self.close() | ||
msg = "failed to read complete page from file (read {:d} of {:d} bytes)" | ||
raise ValueError(msg.format(len(self._cached_page), self._page_length)) | ||
msg = ( | ||
"failed to read complete page from file (read " | ||
f"{len(self._cached_page):d} of " | ||
f"{self._page_length:d} bytes)" | ||
) | ||
raise ValueError(msg) | ||
|
||
self._read_page_header() | ||
page_type = self._current_page_type | ||
|
@@ -725,8 +726,6 @@ def _chunk_to_dataframe(self): | |
js += 1 | ||
else: | ||
self.close() | ||
raise ValueError( | ||
"unknown column type {type}".format(type=self._column_types[j]) | ||
) | ||
raise ValueError(f"unknown column type {self._column_types[j]}") | ||
|
||
return rslt |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,8 +367,8 @@ def _read_header(self): | |
fl = field["field_length"] | ||
if field["ntype"] == "numeric" and ((fl < 2) or (fl > 8)): | ||
self.close() | ||
msg = "Floating field width {0} is not between 2 and 8." | ||
raise TypeError(msg.format(fl)) | ||
msg = "f{Floating field width {fl} is not between 2 and 8.}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How very sloppy of me... Good eye, it has been fixed now. |
||
raise TypeError(msg) | ||
|
||
for k, v in field.items(): | ||
try: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've been cleaning these up elsewhere; shouldn't need the
str()
callThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed, thanks