Skip to content

[Python] Fix Array.length/.Length to use len() for plain list interop#4342

Merged
dbrattli merged 2 commits intomainfrom
dbrattli/fable-python-array-len
Feb 11, 2026
Merged

[Python] Fix Array.length/.Length to use len() for plain list interop#4342
dbrattli merged 2 commits intomainfrom
dbrattli/fable-python-array-len

Conversation

@dbrattli
Copy link
Collaborator

Summary

  • Fix Array.length, .Length, Array.isEmpty, and ResizeArray.Count to compile to len() instead of .length property access in Python
  • The .length property only exists on FSharpArray (Rust-backed) but breaks on plain Python lists from Emit, unbox, or native APIs like json.loads
  • len() works universally since FSharpArray implements __len__, and is wrapped in int32() to preserve the expected return type
  • Add regression tests that exercise Array.length, .Length, and Array.isEmpty on plain Python lists via emitPyExpr

@github-actions
Copy link

Python Type Checking Results (Pyright)

Metric Value
Total errors 13
Files with errors 2
Excluded files 2
New errors ✅ No
Excluded files with errors (2 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

@dbrattli dbrattli merged commit 7883ecc into main Feb 11, 2026
23 checks passed
@dbrattli dbrattli deleted the dbrattli/fable-python-array-len branch February 11, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant