-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Updated .format() to f-strings #30027
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
Conversation
pandas/io/html.py
Outdated
@@ -846,7 +846,7 @@ def _parser_dispatch(flavor): | |||
|
|||
|
|||
def _print_as_set(s) -> str: | |||
return "{" + "{arg}".format(arg=", ".join(pprint_thing(el) for el in s)) + "}" | |||
return f"{{{', '.join(pprint_thing(el) for el in s)}}}" |
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.
join on previous line pls
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.
Thanks for the PR. Looks good if you can address @jbrockmendel suggestions and I think CI failures are unrelated / have been fixed on master since this was created.
To be sure, can you locally on your f-strings
branch run:
git fetch upstream
git merge upstream/master
git push origin f-strings
I think should get CI green for this. Flag me down at PyData if you have any questions
CI failures fixed on master.
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.
lgtm @jbrockmendel
@@ -846,7 +846,8 @@ def _parser_dispatch(flavor): | |||
|
|||
|
|||
def _print_as_set(s) -> str: | |||
return "{" + "{arg}".format(arg=", ".join(pprint_thing(el) for el in s)) + "}" | |||
arg = ", ".join(pprint_thing(el) for el in s) | |||
return f"{{{arg}}}" |
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.
is this adding a layer of braces?
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.
you might be able to get rid of the pprint_thing, not sure
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.
The double brace is how to add a literal brace in an f-string, so looks OK
@@ -616,8 +616,8 @@ def _build_xpath_expr(attrs) -> str: | |||
if "class_" in attrs: | |||
attrs["class"] = attrs.pop("class_") | |||
|
|||
s = [f"@{k}={repr(v)}" for k, v in attrs.items()] | |||
return "[{expr}]".format(expr=" and ".join(s)) | |||
s = " and ".join([f"@{k}={repr(v)}" for k, v in attrs.items()]) |
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.
if you end up making another pass through this file, can you do this in two lines? i.e. keep s
as it is now and do the join in a separate step
Thanks @dlalap congrats on first PR. If you'd like to address some suggestions from @jbrockmendel in a follow up would certainly welcome, along with any other contributions |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff