Skip to content

Bug: Multi-line f-string concatenation not converted #34

@swernerx

Description

@swernerx

Description

Python allows implicit string concatenation across multiple lines, including f-strings. This pattern is not being properly converted to a single template literal.

Python Input

fmt = (f'Machine parameters for {dtype}\n'
       f'---------------------------------------------------------------\n'
       f'precision = {precision}   resolution = {resolution}\n'
       f'machep = {machep}   eps = {eps}\n')

Current Output (v1.3.3)

let fmt = (f'Machine parameters for {this.dtype}\n'
        f'---------------------------------------------------------------\n'
        f'precision = {precision}   resolution = {resolution}\n'
        f'machep = {machep}   eps =        {eps}\n');
// ❌ INVALID - Multiple f-strings not concatenated!

Expected Output

const fmt = \`Machine parameters for \${dtype}
---------------------------------------------------------------
precision = \${precision}   resolution = \${resolution}
machep = \${machep}   eps = \${eps}
\`;

Or with explicit concatenation:

const fmt = 
  \`Machine parameters for \${dtype}\n\` +
  \`---------------------------------------------------------------\n\` +
  \`precision = \${precision}   resolution = \${resolution}\n\` +
  \`machep = \${machep}   eps = \${eps}\n\`;

Priority

🔴 Critical - Causes ~100+ errors in NumPy migration

Files Affected

  • numpy/_core/getlimits.py (multiple occurrences)
  • numpy/_core/_internal.py
  • Other files with multi-line f-strings

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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