Add automatic .py extension for script initialization#12328
Add automatic .py extension for script initialization#12328chhoumann wants to merge 2 commits intoastral-sh:mainfrom
Conversation
When initializing a script with , automatically append .py extension if the user didn't specify it.
59fc393 to
609ab37
Compare
|
I noticed the test My local testing shows the new The error message in the failing test changed slightly in format. Happy to help address this if needed, or we could handle it in a separate PR if that would be preferred. Thanks for reviewing! |
…ormat (#12330) ## Summary Fixes the failing `cache_prune::prune_unzipped` test that was causing CI failures in my other PR (#12328) and others like PR #12327. The error message format changed to show a specific version constraint (`iniconfig<=2.0.0`) rather than the generic 'all versions' message. This PR updates the test to expect the new, more specific error message. ## Test Plan Ran `cargo test -p uv cache_prune::prune_unzipped` to verify the test now passes.
|
I think if we want to do this, we'll probably want to do it everywhere |
|
I think we're leaning away from this for now — it's valid to write Python scripts without the extension. Thanks for contributing though. |
|
Thanks for considering this idea! Totally understand that Python doesn't require extensions. Appreciate the feedback and looking forward to finding other ways to contribute to uv! |
Summary
When initializing a script with
uv init --script, automatically append .py extension if the user didn't specify it.This is a quality-of-life feature that follows the principle of least surprise. Most users would expect a Python script to have a .py extension, and many may forget to add it manually. At least, I did prior to making this PR :)
Test Plan
Added a new test case
init_script_auto_py_extension()that verifies the behavior works correctly: