From 89f9d94593badc024714b2a59aa5672392388ae9 Mon Sep 17 00:00:00 2001 From: Dag Brattli Date: Tue, 9 Jun 2026 23:11:22 +0200 Subject: [PATCH] refactor(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) --- src/Fable.Transforms/Python/Replacements.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fable.Transforms/Python/Replacements.fs b/src/Fable.Transforms/Python/Replacements.fs index a289df5fe9..731d72b4e7 100644 --- a/src/Fable.Transforms/Python/Replacements.fs +++ b/src/Fable.Transforms/Python/Replacements.fs @@ -1678,8 +1678,8 @@ let formattableString (args: Expr list) = match i.CompiledName, thisArg, args with - | "Create", None, [ str; args ] -> objExpr [ "str", str; "args", args ] |> Some - | "get_Format", Some x, _ -> getFieldWith r t x "str" |> Some + | "Create", None, [ str; args ] -> objExpr [ "fmt", str; "args", args ] |> Some + | "get_Format", Some x, _ -> getFieldWith r t x "fmt" |> Some | "get_ArgumentCount", Some x, _ -> // Use int32(len()) to ensure consistent return type let lenExpr =