-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discover and respect .python-version
files in parent directories
#6370
base: tracking/050
Are you sure you want to change the base?
Conversation
916db9c
to
df3693e
Compare
c43d54f
to
1e375ef
Compare
1e02b28
to
2ca5bb4
Compare
2ca5bb4
to
6f07881
Compare
6f07881
to
3564e75
Compare
984c0dc
to
0c31b66
Compare
options | ||
.stop_discovery_at | ||
.and_then(Path::parent) | ||
.map(|stop_discovery_at| stop_discovery_at != *path) | ||
.unwrap_or(true) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code isn't used in production, but this updates the behavior in tandem with copying the implementation for PythonVersionFile::discover
to solve a common footgun where you pass the project root as the place to stop discovery and discovery stopped before looking in that directory.
0c31b66
to
932048f
Compare
pub(crate) async fn from_request( | ||
python_request: Option<PythonRequest>, | ||
workspace: &Workspace, | ||
workspace: Option<&Workspace>, | ||
project_dir: &Path, | ||
) -> Result<Self, ProjectError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making workspace
optional here, I might introduce a new abstraction which is used by WorkspacePython
? It's doing a bit more work than it ought to as-is, but it's not clear another abstraction is worth it.
932048f
to
6ed2dc0
Compare
} = ScriptPython::from_request( | ||
python.as_deref().map(PythonRequest::parse), | ||
None, | ||
&Pep723Item::Script(script.clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly, I don't see a way to avoid this clone unless we make PEP723Item
accept a borrowed script or create an into_script -> Option<...>
method which we'd unwrap later. I think since it's in add
it's fine to clone.
I'll do a self-review of this too. It'd been a minute since I wrote it... |
Uses #6369 for test coverage.
Updates version file discovery to search up into parent directories. Also refactors Python request determination to avoid duplicating the user request / version file / workspace lookup logic in every command (this supersedes the work started in #6372).
There is a bit of remaining work here, mostly around documentation. There are some edge-cases where we don't use the refactored request utility, like
uv build
— I'm not sure how I'm going to handle that yet as it needs a separate root directory.