Skip to content

Unpacked tuples inside f-strings are not allowed on the native parser #620

@isidentical

Description

@isidentical

Short reproducer;

f'{1, 2}'
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 839, in <module>
    main(os.environ.get("LIBCST_TOOL_COMMAND_NAME", "libcst.tool"), sys.argv[1:])
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 834, in main
    return lookup.get(args.action or None, _invalid_command)(proc_name, command_args)
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 278, in _print_tree_impl
    tree = parse_module(
  File "/home/isidentical/projects/LibCST/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
  File "/home/isidentical/projects/LibCST/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:7.
parser error: error at 1:6: expected one of !, !=, %, &, (, *, **, +, -, ., /, //, :, <, <<, <=, =, ==, >, >=, >>, @, ASYNC, [, ^, and, for, if, in, is, not, or, |, }

f'{1, 2}'
      ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions