Skip to content

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

Merged
merged 8 commits into from
Dec 4, 2019

Conversation

ForTimeBeing
Copy link
Contributor

@ForTimeBeing ForTimeBeing commented Nov 27, 2019

xref #29547

  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

More fstring changes

@jreback jreback added the Code Style Code style, linting, code_checks label Nov 27, 2019
@jreback jreback added this to the 1.0 milestone Nov 27, 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.

@ForTimeBeing Thanks for the PR. minor suggestion otherwise lgtm.

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

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

Copy link
Contributor Author

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?

Copy link
Member

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)

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.

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

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?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

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

Copy link
Contributor Author

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")

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

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.

Yep if you can make change as suggested by @simonjayhawkins would be great, otherwise lgtm

@jreback
Copy link
Contributor

jreback commented Nov 29, 2019

can you merge master; ping on green.

@jreback jreback merged commit 21c93fc into pandas-dev:master Dec 4, 2019
@jreback
Copy link
Contributor

jreback commented Dec 4, 2019

thanks @ForTimeBeing

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 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