simonpercivall / astunparse

An AST unparser for Python
Other
223 stars 53 forks source link

#18: Fix formatted string with only one value, like `f{foo}` #19

Closed nvbn closed 6 years ago

nvbn commented 7 years ago

Before:

In [1]: import ast
In [2]: from astunparse import unparse
In [3]: print(unparse(ast.parse('f"{foo}"')))

{foo}

After:

In [1]: import ast
In [2]: from astunparse import unparse
In [3]: print(unparse(ast.parse('f"{foo}"')))

f'''{foo}'''
nvbn commented 7 years ago

Tests failed on travis-ci with python 3.2 with unrelated error - https://travis-ci.org/simonpercivall/astunparse/jobs/230798076

0.20s$ python setup.py test
Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    from setuptools import setup, find_packages
  File "/home/travis/virtualenv/python3.2.6/lib/python3.2/site-packages/setuptools/__init__.py", line 12, in <module>
    import setuptools.version
  File "/home/travis/virtualenv/python3.2.6/lib/python3.2/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/home/travis/virtualenv/python3.2.6/lib/python3.2/site-packages/pkg_resources/__init__.py", line 77, in <module>
    raise RuntimeError("Python 3.3 or later is required")
RuntimeError: Python 3.3 or later is required
graingert commented 7 years ago

@nvbn if you rebase on https://github.com/simonpercivall/astunparse/pull/21 you can get the tests passing.