-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
String formatting > fstring #29892
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
String formatting > fstring #29892
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.
@ForTimeBeing Thanks for the PR. minor suggestion otherwise lgtm.
pandas/tseries/frequencies.py
Outdated
@@ -260,8 +260,7 @@ def infer_freq(index, warn=True): | |||
if isinstance(index, pd.Index) and not isinstance(index, pd.DatetimeIndex): | |||
if isinstance(index, (pd.Int64Index, pd.Float64Index)): | |||
raise TypeError( | |||
"cannot infer freq from a non-convertible index " | |||
"type {type}".format(type=type(index)) | |||
"cannot infer freq from a non-convertible index " f"type {type(index)}" |
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.
can you manually concatenate these two literals
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.
Sorry, maybe I am misunderstanding you. Do you mean to make them each 1 string instead of 2?
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.
yes. just this one. (it's a result of the black reformatting)
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.
@ForTimeBeing Thanks. lgtm pending green.
@@ -1007,7 +1007,7 @@ def test_cumsum(self, data, expected, numpy): | |||
np.cumsum(SparseArray(data), out=out) | |||
else: | |||
axis = 1 # SparseArray currently 1-D, so only axis = 0 is valid. | |||
msg = "axis\\(={axis}\\) out of bounds".format(axis=axis) | |||
msg = f"axis\\(={axis}\\) out of bounds" |
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.
do "f" and "r" prefixes play nicely together?
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 will need to add repr won't I since fstring defaults to str()?
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.
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 would prefer to use re.escape than use raw string
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.
Like so?
re.escape(f"axis(={axis}) out of bounds")
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.
that looks correct. does it work?
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.
It passes the git diff test and compiles, I am unsure how to test that exact line unfortunately. Trying to learn but that is beyond me. This is the biggest project ive worked on
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.
This is part of a test. so OK if tests passing.
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.
Yep if you can make change as suggested by @simonjayhawkins would be great, otherwise lgtm
can you merge master; ping on green. |
thanks @ForTimeBeing |
xref #29547
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
More fstring changes