Skip to content

The any key/p38 self documenting fstrings #1899

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

Conversation

TheAnyKey
Copy link
Contributor

This PR contains the following changes for fstring:

fix: so far it was not allowed that a conversion flag is followed by a format specifier.

so far f"{'42'!s:10}" rose a parsing error as a '}' was expected after a conversion flag.This is fix now.

implemented self documenting fstrings in rustpython

I implemented the self documenting fstrings in rustpython, as introduced with python 3.8. I.e., the following syntax is now allowed:

foo="bar"
f"{foo=}"
foo=bar
f"{221=}"
2
21=42
...

Also combination with conversion flags and format specs are supported.

Open: the behaviour when the type of the expression is a string is so far not conform to cpython, thus those are temporarily modified or skipped.

Ported tests from cpython for self documenting fstrings (and some more for format spec handling)

Imported the tests for selfdocumentign fstrings from cpython to rustpython.

TheAnyKey and others added 3 commits May 4, 2020 23:09
Co-authored-by: Jeong YunWon <youknowone@users.noreply.github.com>
Copy link
Member

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

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

Thank you for contributing!

@coolreader18 coolreader18 dismissed youknowone’s stale review May 5, 2020 15:24

changes addressed

@coolreader18 coolreader18 merged commit c6d3b1b into RustPython:master May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants