Skip to content

Conversation

@alimcmaster1
Copy link
Member

@alimcmaster1 alimcmaster1 commented Nov 10, 2019

Old style % formatting to f-strings

formatter = lambda dt: dt.strftime(date_format)
else:
formatter = lambda dt: "%s" % dt
formatter = lambda dt: f"{dt}"
Copy link
Member

Choose a reason for hiding this comment

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

would str(dt) be clearer here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure - agree

return None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
Copy link
Member

Choose a reason for hiding this comment

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

i think this file is auto-generated

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted

index=index,
partition_cols=partition_cols,
**kwargs
**kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

is this a black version thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Weirdly using 19.3b0 locally seems to add this for me - I've reverted

Copy link
Member Author

@alimcmaster1 alimcmaster1 Nov 11, 2019

Choose a reason for hiding this comment

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

Black code check in CI fail without this - i've added this back in

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I find this quite odd that you have to add a comma at the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Related to this - #29607

@jbrockmendel
Copy link
Member

looks like black complaints

@alimcmaster1
Copy link
Member Author

@jbrockmendel - ready to re-review whenever you have a moment

space = self._format_space()

prepr = (",%s" % space).join("%s=%s" % (k, v) for k, v in attrs)
prepr = f",{space}".join(f"{k}={v}" for k, v in attrs)
Copy link
Member

Choose a reason for hiding this comment

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

let's try to minimize what we execute in f-space (better name for this?)

if hasattr(tail, "format") and not isinstance(tail, str):
tail = tail.format()
index_summary = ", %s to %s" % (pprint_thing(head), pprint_thing(tail))
index_summary = f", {pprint_thing(head)} to {pprint_thing(tail)}"
Copy link
Member

Choose a reason for hiding this comment

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

pprint_thing may be unnecessary here now that we're py3-only. can you take a look

)

freq = "%dL" % self._get_interval()
freq = f"{self._get_interval()}L"
Copy link
Member

Choose a reason for hiding this comment

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

call get_intterval outside

Copy link
Member Author

Choose a reason for hiding this comment

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

fair point - done

freq = self.freqstr
if freq is not None:
freq = "'%s'" % freq
freq = f"'{freq}'"
Copy link
Member

Choose a reason for hiding this comment

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

do the single quotes become unnecessary with a {freq:r} or something like that? This is a pretty common pattern, but we aren't very consistent about when we do or dont use the quotes (i sometimes use ticks like for markdown)

Copy link
Member Author

Choose a reason for hiding this comment

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

Assuming you mean {freq!r} here - updated. Agree doesn't seem to be much consistency

@jbrockmendel
Copy link
Member

A handful of comments, general rule about minimizing the code that is executed inside f-space. If its viable to have the black-version-related stuff not in this diff that'll make it a little easier. cc @gfyoung for another look

@gfyoung
Copy link
Member

gfyoung commented Nov 15, 2019

Looks pretty good! I agree with the comments here.

@alimcmaster1
Copy link
Member Author

Updated as per comments and green cc. @jbrockmendel and @gfyoung

@jreback jreback added this to the 1.0 milestone Nov 18, 2019
@jreback jreback merged commit c236491 into pandas-dev:master Nov 18, 2019
@jreback
Copy link
Contributor

jreback commented Nov 18, 2019

thanks @alimcmaster1

Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
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
@alimcmaster1 alimcmaster1 deleted the mcmali-pyup branch December 25, 2019 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants