support multiple values for `python-platform`
it's very common for python projects to be run on multiple platforms (especially if you're developing a library). python-platform should support specifying an array of values eg:
python-platform = ["linux", "win32"]
and maybe an "all" option as well, which both ty and pyright support
Thanks for the request, @DetachHead! Verified pyrefly does NOT support this today, and there's actually a related footgun worth flagging.
Current state (confirmed against HEAD):
| Config | Result |
|---|---|
python-platform = ["linux", "win32"] |
Rejected: invalid type: sequence, expected a string |
python-platform = "all" |
Silently accepted as a custom unknown platform name |
python-platform = "All" |
Silently aliased to "linux" (not multi-platform!) |
The PythonPlatform config is a String newtype, single-value-only (crates/pyrefly_python/src/sys_info.rs:177). The constructor PythonPlatform::new normalizes "All" → linux for Pyright compatibility, but doesn't implement actual multi-platform semantics — so users who pass "All" thinking they're getting multi-platform coverage are silently only checking linux. That's a footgun worth fixing as part of this work.
Two-part fix:
- Config schema — accept
python-platform: ["linux", "win32"](array form) and have"all"/"All"mean the actual union of all known platforms (not silently aliased to linux). - Type-check propagation — wherever pyrefly currently uses the configured platform to gate symbol availability or narrow
sys.platform, it needs to consider the union of configured platforms. A symbol should be treated as available if it exists on any configured platform;sys.platformnarrowed branches under multi-platform mode shouldn't narrow to a single concrete value.
Both ty and pyright already support this pattern. Adopting the same shape would help migration.
Tagging @connernilsen for routing (config surface).
Hey @DetachHead, thanks for submitting this issue. I've been thinking about this while reading your post, and I think it's a reasonable thing to add. I'll open it up to external contribution.
Picking this up to see if I can land a solution to this problem.
@asukaminato0721 thank you for putting out the PR, I will unassign myself.
claim