fix: ensure all diagnostic paths in baseline are relative#3007
fix: ensure all diagnostic paths in baseline are relative#3007yeetypete wants to merge 9 commits intofacebook:mainfrom
Conversation
|
oh dear, looks like I have to fix some windows path stuff... Edit: I changed a bit more than I'd have liked to to accomodate Windows paths. I think it makes sense that the baseline files are cross platform so I decided to always store the paths in the baseline in unix format. lmk if this is too much of a drastic change. |
…g forward slash paths
|
Hey @yeetypete, thanks for working on this! Making the baseline paths relative is definitely a win for CI consistency. Full disclosure: I’m not a maintainer or regular contributor, just a developer looking through PRs and giving feedback as I get to know the codebase. I noticed the mypy_primer (7) check is failing, but you can probably ignore that for now. There’s been a lot of talk on the Discord about this being a known infrastructure issue affecting several PRs, so it doesn't seem related to your changes in relativize.rs. One technical question: for the Relativize() trait, how does it handle cases where files are on different drive letters on Windows (e.g., project on C: but a library on D:)? Since a relative path can't cross drives, I'm curious if the logic falls back to an absolute path or if that's handled elsewhere. |
Thanks for this, I was just about to file an issue, when I noticed that my Windows-generated baseline.json did not seem to apply at all on our Linux CI for this reason. |
https://pyrefly.org/ See also upstream PR Deltares/Ribasim#3019 This is now checked in CI just like Mypy was before. It just checks better and faster. To run it locally run ``` uv run pyrefly check ``` This is also in the dev docs. There were many typing failures that would be too much to fix directly. So this adds a baseline.json file with all current errors. New code cannot add new failures, but these existing issues can be gradually fixed over time. I also added some more return type annotations with [`pyrefly infer`](https://pyrefly.org/en/docs/autotype/). There is a small workaround for the paths in baseline.json that can be removed after facebook/pyrefly#3007 is released.
|
@Arths17 yes, at the moment paths pointing to a different drive letter will fall back to being absolute. I don't know a good way around this but I also don't know why one would want to distribute code across different drive letters. That sounds very fragile. Alternatively we can choose to fail hard here and prevent such behavior, but idk if thats worth doing. |
Summary
Fixes #2547
When pyrefly writes
baseline.json, files located outside the current working directory (e.g. referenced via../../libs/fooinsearch-path) were stored with absolute paths. This breaks baseline matching in CI where the checkout path differs from a local dev environment.Changes:
BaselineKeynow always contains absolute paths. This decouples key comparison from the path format (relative or absolute) in the baseline file on disk.Test Plan
pyrefly checkstill works with an older absolute path baseline, and that regenerating the baseline creates one with relative paths. Then tested to make surepyrefly checkworks on the new baseline.