-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
CLN: Update old string formatting to f-string #30631
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
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. ping on green
@thepaullee can you have a look at the CI please? Seems like some things are broken. |
pandas/core/ops/array_ops.py
Outdated
@@ -246,17 +246,16 @@ def comparison_op( | |||
res_values = comp_method_OBJECT_ARRAY(op, lvalues, rvalues) | |||
|
|||
else: | |||
op_name = "__{op}__".format(op=op.__name__) | |||
op_name = f"__{op.__name__}" |
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.
op_name = f"__{op.__name__}" | |
op_name = f"__{op.__name__}__" |
Thanks @thepaullee! Do the maintainers have a preferred style for the changes introducing temporary variables just for f-strings? For example, https://github.com/pandas-dev/pandas/pull/30631/files#diff-f91291af4cee29af665968c2ffd05013R105-R106 isn't an obvious improvement to me. |
"and scalar of type [{typ}]".format( | ||
op=op.__name__, dtype=x.dtype, typ=type(y).__name__ | ||
) | ||
f"Cannot perform '{op.__name__}' with a dtyped [{x.dtype}] array " |
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 agree with @TomAugspurger here - i would simply in-line this rather than creating a temporary
temporary only if it’s a really complicated expr or has quoting itself (eg a .join(..)
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Updates:
pandas/core/ops/array_ops.py
pandas/core/ops/dispatch.py
pandas/core/ops/docstrings.py
pandas/core/ops/invalid.py
pandas/core/ops/methods.py
pandas/core/ops/roperator.py