Commit d12fa79
[Python/Beam] Align random* error messages with .NET and fix pyright errors
Review follow-ups for #4488:
Python:
- Delete orphaned fable-library-py/fable_library/Array.fs (not in fsproj,
declared module ArrayModule, never compiled).
- Replace bare PyException("argname") raises in Rust extension with
PyValueError carrying descriptive messages aligned with dotnet/fsharp
FSharp.Core resource strings. Randomizer validation now matches .NET's
dynamic format exactly, including the actual returned value.
- Fix core/array.pyi: change Callable[[], float] -> Callable[[], SupportsFloat]
for all 15 random *_by signatures. Fable transpiles F# (fun () -> 0.0) as
returning Float64, which caused 13 pyright errors in test_array.py.
Beam:
- Align randomizer error message with .NET's dynamic format via io_lib:format.
- Use andalso in random_sample_by guard (idiomatic Erlang).
- Refactor random_choices_by: drop lists:map + lists:seq + lists:nth O(n)
per-pick and use a tail-recursive choices_loop/5 helper with list_to_tuple
for O(1) indexed access, matching the pattern used by shuffle_loop and
sample_loop in the same file.
Verification:
- cargo check fable-library-core: clean
- ./build.sh test python: 2233 passed, 0 failed
- pyright on temp/tests/Python/: 0 errors (was 13)
- ./build.sh test beam: 2390 passed, 0 failed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent e870773 commit d12fa79
4 files changed
Lines changed: 67 additions & 1388 deletions
File tree
- src
- fable-library-beam
- fable-library-py
- fable_library
- core
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
| 660 | + | |
| 661 | + | |
660 | 662 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
| |||
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
697 | | - | |
| 697 | + | |
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
| |||
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | | - | |
| 721 | + | |
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
737 | | - | |
| 737 | + | |
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| |||
0 commit comments