Vyper: Upgrade to all f-strings

Created on 8 Aug 2019  路  3Comments  路  Source: vyperlang/vyper

What's your issue about?

The code uses a mix of %s, .format(), and f"", which can be confusing which style we prefer.

How can it be fixed?

Change it all to one style, preferably f-strings.

Also, document this in the style guide

Easy Pickings enhancement help wanted

All 3 comments

I'd like to take this. 2 questions:
1) When would you like to have this done by?
2) Where is the style guide?

I just started poking around, and quickly ran into another issue:
I see that there are places where byte strings are formatted (see vyper/tests/types/test_bytes_literal.py on lines 48, 56, and 67 as of when I'm writing this), and there doesn't seem to be any way to make a 'byte-fstring' (in fact, even .format doesn't work, only % and some other hacks). What should the format be for byte strings that need formatting?

So, you can format a string literal as bytes via .encode("utf-8"):

>>> "m12mm345mm".encode("utf-8")
b'm12mm345mm'
>>> "m12mm345mm{}".format("afgs").encode("utf-8")
b'm12mm345mmafgs'
>>> stuff = "afgafdg"
>>> f"m12mm345mm{stuff}".encode("utf-8")
b'm12mm345mmafgafdg'

Thank you for taking this on!

As far as your questions, 1) whenever you can get it done by is fine, just set up a PR with "fixes #1567" in it (so it links back to this one) so we know what the progress is, and 2) not sure we have a style guide for how to write f-strings, if you have questions just ping us in the gitter. Thank you again!

Was this page helpful?
0 / 5 - 0 ratings