Skip to content

Commit 3abe301

Browse files
dbrattliclaude
andcommitted
fix(python): rename FormattableString field from str to fmt
The Python representation of FormattableString used a field literally named `str`, producing an object expression with a `@property def str`. While this runs correctly (the `-> str` return annotation resolves to the builtin under PEP 563, and Pyright accepts it), Astral's `ty` type checker resolves the annotation against the class-scoped `str` property and reports a false-positive `invalid-type-form` error. Rename the internal field to `fmt`, which sidesteps the builtin-name collision entirely. The field is internal to the `formattableString` replacement (written by `Create`, read by `get_Format`), so the change is fully self-contained. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4c36f76 commit 3abe301

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Fable.Transforms/Python/Replacements.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,8 @@ let formattableString
16781678
(args: Expr list)
16791679
=
16801680
match i.CompiledName, thisArg, args with
1681-
| "Create", None, [ str; args ] -> objExpr [ "str", str; "args", args ] |> Some
1682-
| "get_Format", Some x, _ -> getFieldWith r t x "str" |> Some
1681+
| "Create", None, [ str; args ] -> objExpr [ "fmt", str; "args", args ] |> Some
1682+
| "get_Format", Some x, _ -> getFieldWith r t x "fmt" |> Some
16831683
| "get_ArgumentCount", Some x, _ ->
16841684
// Use int32(len()) to ensure consistent return type
16851685
let lenExpr =

0 commit comments

Comments
 (0)