Skip to content

Comments

Warn when project-specific settings are passed to non-project uv run commands#5977

Merged
charliermarsh merged 1 commit intomainfrom
charlie/warn-run
Aug 9, 2024
Merged

Warn when project-specific settings are passed to non-project uv run commands#5977
charliermarsh merged 1 commit intomainfrom
charlie/warn-run

Conversation

@charliermarsh
Copy link
Member

Summary

Closes #5856.

@charliermarsh charliermarsh added cli Related to the command line interface preview Experimental behavior labels Aug 9, 2024
@charliermarsh charliermarsh requested a review from zanieb August 9, 2024 20:22
}
if frozen {
warn_user_once!("`--frozen` has no effect alongside `--no-project`");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could enforce these specific warnings via Clap, and make them errors. But the others must be done at runtime, because we don't know if we'll discover a project when we first parse the arguments. So I just did them all as warnings for consistency.

let base_interpreter = if let Some(script_interpreter) = script_interpreter {
// If we found a PEP 723 script and the user provided a project-only setting, warn.
if !extras.is_empty() {
warn_user_once!("Extras are not supported for Python scripts");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change this to show specific CLI arguments when I do #5855 (I'll need access to the args to fix that).


----- stderr -----
Reading inline script metadata from: main.py
warning: `--no-project` is a no-op for Python scripts, which always run in isolation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python scripts with inline metadata — not all Python scripts.


----- stderr -----
warning: `uv run` is experimental and may change without warning
warning: `--locked` has no effect alongside `--no-project`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor preference for "when used with" instead of "alongside".

// If we can't find a project and the user provided a project-only setting, warn.
if project.is_none() {
if !extras.is_empty() {
warn_user_once!("Extras were provided, but no project was found");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extras were "requested"?

@zanieb
Copy link
Member

zanieb commented Aug 9, 2024

Is this the only interface this applies to? Thank you!

@charliermarsh
Copy link
Member Author

Arguably also no_workspace in uv init (warn if you're not in a workspace).

@charliermarsh charliermarsh enabled auto-merge (squash) August 9, 2024 23:06
@charliermarsh charliermarsh merged commit a3b1a4b into main Aug 9, 2024
@charliermarsh charliermarsh deleted the charlie/warn-run branch August 9, 2024 23:10
zanieb added a commit that referenced this pull request Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command line interface preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when project options are used with uv run outside a project

2 participants