fix Upward Find for venv #759#2791
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Pyrefly’s virtual environment discovery to search upward through ancestor directories so a project can use a .venv located in a parent directory (addresses #759).
Changes:
- Refactors venv discovery into a per-root helper (
find_in_root) and applies it acrossproject_pathancestors. - Adds unit tests ensuring ancestor search works and prefers the nearest matching ancestor venv.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
connernilsen
left a comment
There was a problem hiding this comment.
Hey @asukaminato0721, thanks for doing this. This has been on the todo list for a while, so it's awesome that you picked it up.
There are a few requests below, but I don't think they should be too difficult to fix. Let me know if you have further questions or want to discuss anything.
8dcfb9d to
287a4d5
Compare
connernilsen
left a comment
There was a problem hiding this comment.
Two more minor things, then I'll pull it in and merge it :)
connernilsen
left a comment
There was a problem hiding this comment.
Thanks for working on this!
|
@connernilsen has imported this pull request. If you are a Meta employee, you can view this in D98169929. |
Summary
Fixes #759
keeping the existing per-root scan and applying it across project_path plus its ancestors, so Pyrefly now finds the nearest ancestor .venv instead of only searching downward from the current root.
Test Plan
add test