Skip to content

%s changed to fstring, single quotes in f string changed to double qu… #30108

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
Dec 24, 2019
Merged

%s changed to fstring, single quotes in f string changed to double qu… #30108

merged 3 commits into from
Dec 24, 2019

Conversation

Behemkot
Copy link
Contributor

@Behemkot Behemkot commented Dec 6, 2019

#29547 (comment)
#29547

  • pandas/_libs/tslibs/frequencies.pyx
  • pandas/_libs/tslibs/period.pyx
  • pandas/_libs/tslibs/strptime.pyx

changed %s to f strings and f ' ' to f " ".
str.format() remained unchanged due to:
#29547 (comment)

@@ -1209,8 +1209,7 @@ def period_format(int64_t value, int freq, object fmt=None):
elif freq_group == 4000: # WK
left = period_asfreq(value, freq, 6000, 0)
right = period_asfreq(value, freq, 6000, 1)
return '%s/%s' % (period_format(left, 6000),
period_format(right, 6000))
return f"(period_format(left, 6000)/period_format(right, 6000))"
Copy link
Member

Choose a reason for hiding this comment

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

are we calling this function inside a loop? if so, we may need to be careful about whether cython fstrings differently from % formatting

Copy link
Member

Choose a reason for hiding this comment

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

more generally, id prefer to have non-trivial function calls occur outside of f-space.

Copy link
Member

Choose a reason for hiding this comment

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

the CI failures look related to this

@alimcmaster1 alimcmaster1 added Code Style Code style, linting, code_checks Clean labels Dec 6, 2019
@alimcmaster1
Copy link
Member

#30094 can you submit updates on the same PR opposed to a new PR in the future

@@ -1209,8 +1209,7 @@ def period_format(int64_t value, int freq, object fmt=None):
elif freq_group == 4000: # WK
left = period_asfreq(value, freq, 6000, 0)
right = period_asfreq(value, freq, 6000, 1)
return '%s/%s' % (period_format(left, 6000),
period_format(right, 6000))
return f"(period_format(left, 6000)/period_format(right, 6000))"
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
return f"(period_format(left, 6000)/period_format(right, 6000))"
return f"{period_format(left, 6000}/{period_format(right, 6000}"

Copy link
Member

Choose a reason for hiding this comment

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

just pushed this change. it fixed the errors for locally

@jbrockmendel
Copy link
Member

LGTM

@jbrockmendel
Copy link
Member

over to you @WillAyd

@WillAyd WillAyd merged commit e81faa1 into pandas-dev:master Dec 24, 2019
@WillAyd
Copy link
Member

WillAyd commented Dec 24, 2019

Thanks @Behemkot and @jbrockmendel

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

Successfully merging this pull request may close these issues.

4 participants