Skip to content
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

Add support for f-strings #166

Merged
merged 4 commits into from Aug 26, 2019
Merged

Add support for f-strings #166

merged 4 commits into from Aug 26, 2019

Conversation

malthe
Copy link
Contributor

@malthe malthe commented Jul 3, 2019

This fixes #123.

Note that f-strings are very different from using str.format since they're actually compiled to bytecode and thus the restricted exec transformer is able to work its magic on the expression contained.

@malthe malthe requested a review from icemac July 5, 2019 06:17
Copy link
Member

@icemac icemac 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 your PR. I'm mostly fine with it.

Additionally to the requested changes in the code I'd request an entry in the change log referencing the issue this PR fixes.

"""It compiles a function call successfully and returns the used name."""

# F-strings were introduced in Python 3.6.
if version_info.major >= 3 and version_info.minor >= 6:
Copy link
Member

Choose a reason for hiding this comment

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

I'd like these tests to be skipped on Python < 3.6 instead of having no assertion.

We already have a constant for >= 3.6:

IS_PY36_OR_GREATER = _version.major == 3 and _version.minor >= 6

The following code uses a decorator for the skipping:

@pytest.mark.skipif(
not IS_PY35_OR_GREATER,
reason="MatMult was introducted on Python 3.5")
def test_MatMult():

@icemac icemac merged commit c04efab into master Aug 26, 2019
@icemac icemac deleted the add-fstring-support branch August 26, 2019 06:11
@icemac
Copy link
Member

icemac commented Aug 26, 2019

@malthe Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support f-strings in Python 3.6+
2 participants