-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
FormattedValue (fstring) in noworkflow are incorrectly capturing entire string literals instead of parsing and capturing only the literal parts
f"Hello, my name is {name} and I am {age} years old."will give values
| name | type |
|---|---|
| f"Hello, my name is {name} and I am {age} years old." | fstring |
| f"Hello, my name is {name} and I am {age} years old." | literal |
| {name} | fvalue |
| f"Hello, my name is {name} and I am {age} years old." | literal |
| {age} | fvalue |
| f"Hello, my name is {name} and I am {age} years old." | literal |
but the correct literal should captured separately the formatted value (fvalues), as demonstrated in the example below using ast.dump:
Module(
body=[
Expr(
value=JoinedStr(
values=[
Constant(value='Hello, my name is '),
FormattedValue(
value=Name(id='name', ctx=Load()),
conversion=-1),
Constant(value=' and I am '),
FormattedValue(
value=Name(id='age', ctx=Load()),
conversion=-1),
Constant(value=' years old.')]))],
type_ignores=[])
In noworkflow, the equivalent representation should be
| name | type |
|---|---|
| f"Hello, my name is {name} and I am {age} years old." | fstring |
| "Hello, my name is " | literal |
| {name} | fvalue |
| " and I am " | literal |
| {age} | fvalue |
| " years old." | literal |
Reactions are currently unavailable