Skip to content

CLN: Old string formatting: .format() -> f"" #30328

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 5 commits into from
Dec 20, 2019
Merged

CLN: Old string formatting: .format() -> f"" #30328

merged 5 commits into from
Dec 20, 2019

Conversation

baevpetr
Copy link
Contributor

@baevpetr baevpetr commented Dec 18, 2019

@pep8speaks
Copy link

pep8speaks commented Dec 18, 2019

Hello @baevpetr! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-12-18 22:33:08 UTC

@@ -1056,8 +1046,7 @@ def coerce_to_target_dtype(self, other):
return self.astype(object)

raise AssertionError(
"possible recursion in "
"coerce_to_target_dtype: {} {}".format(self, other)
"possible recursion in " f"coerce_to_target_dtype: {self} {other}"
Copy link
Member

Choose a reason for hiding this comment

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

an extra space snuck in the middle here (this is a common occurrence with black)

@@ -1202,8 +1191,7 @@ def _interpolate(
if method in ("krogh", "piecewise_polynomial", "pchip"):
if not index.is_monotonic:
raise ValueError(
"{0} interpolation requires that the "
"index be monotonic.".format(method)
f"{method} interpolation requires that the " "index be monotonic."
Copy link
Member

Choose a reason for hiding this comment

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

extra space

)
raise ValueError(invalid_arg)

if inspect.isclass(dtype) and issubclass(dtype, ExtensionDtype):
msg = (
"Expected an instance of {}, but got the class instead. "
"Try instantiating 'dtype'.".format(dtype.__name__)
f"Expected an instance of {dtype.__name__}, but got the class instead. "
Copy link
Member

Choose a reason for hiding this comment

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

looks like the linter thinks this line is too long

@jbrockmendel
Copy link
Member

Couple of small issues, otherwise this is a nice cleanup, thanks


# check that the key does not exceed the maximum size of the index
if len(arr) and (arr.max() >= len_axis or arr.min() < -len_axis):
raise IndexError("positional indexers are out-of-bounds")
else:
raise ValueError(
"Can only index by location with "
"a [{types}]".format(types=self._valid_types)
"Can only index by location with " f"a [{self._valid_types}]"
Copy link
Member

Choose a reason for hiding this comment

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

extra space crept in, also down on 2059 (im going to stop pointing those out now)

Copy link
Contributor Author

@baevpetr baevpetr Dec 18, 2019

Choose a reason for hiding this comment

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

My fault. Missed them. Working... Expected such things to be fixed by a linter

"None of [{key}] are in the [{axis}]".format(
key=key, axis=self.obj._get_axis_name(axis)
)
f"None of [{key}] are in the [{self.obj._get_axis_name(axis)}]"
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: can you define axis_name = self.obj._get_axis_name(axis) on the previous line and use axis_name inside the fstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@baevpetr
Copy link
Contributor Author

baevpetr commented Dec 18, 2019

So there're some more " f" typos. Fixed them. Sry for commit ddos.

@baevpetr baevpetr changed the title Old string formatting CLN: Old string formatting: .format() -> f"" Dec 19, 2019
@simonjayhawkins simonjayhawkins added the Code Style Code style, linting, code_checks label Dec 20, 2019
@simonjayhawkins simonjayhawkins added this to the 1.0 milestone Dec 20, 2019
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

@baevpetr lgtm.

@jreback jreback merged commit 6efc237 into pandas-dev:master Dec 20, 2019
@jreback
Copy link
Contributor

jreback commented Dec 20, 2019

thanks @baevpetr

@baevpetr baevpetr deleted the old_string_formatting branch December 21, 2019 04:00
AlexKirko pushed a commit to AlexKirko/pandas that referenced this pull request Dec 29, 2019
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.

5 participants