Skip to content

--bounds has no effect for --script #15544

@nik-sm

Description

@nik-sm

Summary

It seems that uv add --bounds exact has no effect when adding dependencies to a script. See example below. If this is intended behavior, I believe the CLI should warn about this.

$ uv init --script example.py                      
Initialized script at `example.py`
$ uv add --script example.py --bounds exact ipython
warning: The `bounds` option is in preview and may change in any future release. Pass `--preview-features add-bounds` to disable this warning.
Updated `example.py`

$ cat example.py 
───────┬─────────────────────────────────────
       │ File: example.py
───────┼─────────────────────────────────────
   1   │ # /// script
   2   │ # requires-python = ">=3.12"
   3   │ # dependencies = [
   4   │ #     "ipython",
   5   │ # ]
   6   │ # ///
   7   │ 
   8   │ 
   9   │ def main() -> None:
  10   │     print("Hello from example.py!")
  11   │ 
  12   │ 
  13   │ if __name__ == "__main__":
  14   │     main()
───────┴─────────────────────────────────────



$ uv init --script example2.py                     
Initialized script at `example2.py`

$ uv add --script example2.py --bounds major ipython
warning: The `bounds` option is in preview and may change in any future release. Pass `--preview-features add-bounds` to disable this warning.
Updated `example2.py`
$ cat example2  
[bat error]: 'example2': No such file or directory (os error 2)

$ cat example2.py 
───────┬──────────────────────────────────────
       │ File: example2.py
───────┼──────────────────────────────────────
   1   │ # /// script
   2   │ # requires-python = ">=3.12"
   3   │ # dependencies = [
   4   │ #     "ipython",
   5   │ # ]
   6   │ # ///
   7   │ 
   8   │ 
   9   │ def main() -> None:
  10   │     print("Hello from example2.py!")
  11   │ 
  12   │ 
  13   │ if __name__ == "__main__":
  14   │     main()
───────┴──────────────────────────────────────

P.S. loving the --script workflow - keep up the great work!

Platform

Darwin 24.5.0 arm64

Version

uv 0.8.13 (ede75fe 2025-08-21)

Python version

Python 3.12.11

Metadata

Metadata

Assignees

Labels

error messagesMessaging when something goes wrong

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions