Skip to content

--with-requirements script doesn't work if script doesn't end with .py #16732

@janlarres

Description

@janlarres

Summary

Save this as file test:

#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["requests"]
# ///

import requests

requests.get("https://google.com")

Then try to run something like ty in its environment:

$ uvx --with-requirements test ty check test
error: Couldn't parse requirement in `test` at position 84
  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `r`
import requests
       ^

If you rename it to test.py it works fine:

$ uvx --with-requirements test.py ty check test.py
Installed 6 packages in 5ms
All checks passed!

Since inline metadata is meant for standalone scripts that usually wouldn't have an extension, it would be really useful if this worked.

Platform

Linux 6.16.3+deb14-amd64 x86_64 GNU/Linux

Version

uv 0.9.9

Python version

Python 3.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions