Skip to content

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

Merged
merged 3 commits into from
Jan 3, 2020

Conversation

thepaullee
Copy link
Contributor

@thepaullee thepaullee commented Jan 2, 2020

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

Copy link
Member

@WillAyd WillAyd left a 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

@WillAyd WillAyd added the Code Style Code style, linting, code_checks label Jan 2, 2020
@WillAyd WillAyd added this to the 1.0 milestone Jan 2, 2020
@datapythonista
Copy link
Member

@thepaullee can you have a look at the CI please? Seems like some things are broken.

@@ -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__}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
op_name = f"__{op.__name__}"
op_name = f"__{op.__name__}__"

@TomAugspurger
Copy link
Contributor

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.

@TomAugspurger TomAugspurger merged commit 94cbc2f into pandas-dev:master Jan 3, 2020
"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 "
Copy link
Contributor

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(..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants