-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
pandas/core/internals/blocks.py
Outdated
@@ -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}" |
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.
an extra space snuck in the middle here (this is a common occurrence with black)
pandas/core/internals/blocks.py
Outdated
@@ -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." |
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.
extra space
pandas/core/internals/blocks.py
Outdated
) | ||
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. " |
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.
looks like the linter thinks this line is too long
Couple of small issues, otherwise this is a nice cleanup, thanks |
pandas/core/indexing.py
Outdated
|
||
# 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}]" |
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.
extra space crept in, also down on 2059 (im going to stop pointing those out now)
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.
My fault. Missed them. Working... Expected such things to be fixed by a linter
pandas/core/indexing.py
Outdated
"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)}]" |
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.
nitpick: can you define axis_name = self.obj._get_axis_name(axis)
on the previous line and use axis_name
inside the fstring?
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.
Done.
So there're some more |
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.
@baevpetr lgtm.
thanks @baevpetr |
black pandas
Old style % formatting to f-strings