Skip to content

Replace .format with f-strings #31627

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

Closed
wants to merge 12 commits into from
7 changes: 3 additions & 4 deletions pandas/util/_print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_sys_info() -> List[Tuple[str, Optional[Union[str, int]]]]:
("python-bits", struct.calcsize("P") * 8),
("OS", f"{sysname}"),
("OS-release", f"{release}"),
# ("Version", "{version}".format(version=version)),
# ("Version", f"{version}"),
("machine", f"{machine}"),
("processor", f"{processor}"),
("byteorder", f"{sys.byteorder}"),
Expand Down Expand Up @@ -114,14 +114,13 @@ def show_versions(as_json=False):

else:
maxlen = max(len(x) for x in deps)
tpl = "{{k:<{maxlen}}}: {{stat}}".format(maxlen=maxlen)
print("\nINSTALLED VERSIONS")
print("------------------")
for k, stat in sys_info:
print(tpl.format(k=k, stat=stat))
print(f"{k}:<{maxlen}: {stat}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this print the same as previous? Previous output has extra {}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
I looked into it changed it.
This is my first time contributing so thanks for the feedback.

print("")
for k, stat in deps_blob:
print(tpl.format(k=k, stat=stat))
print(f"{k}:<{maxlen}: {stat}")


def main() -> int:
Expand Down