astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.04k stars 762 forks source link

feat: uv command to add `exclude-newer` with current date #8991

Open tlambert03 opened 2 days ago

tlambert03 commented 2 days ago

Apologies if I missed an existing feature: I love the exclude-newer feature and wonder where there is a convenience to programmatically populate the exclude-newer field with the "current" timestamp:

# [tool.uv]
# exclude-newer = "<RFC 3339 NOW>"

(something to save looking up the current timestamp and manually editing the file). Looks like using something like uv add --script myscript.py --exclude-newer "2023-10-16T00:00:00Z" some-package doesn't add the tool.uv section

edit: to clarify, I'm looking for some command:

uv <command> <target.py | project>

that would add exclude-newer = <NOW> to the target

tlambert03 commented 2 days ago

probably related to the hypothetical uv config set mentioned in https://github.com/astral-sh/uv/pull/8553

zanieb commented 1 day ago

Hm. We could write exclude-newer during uv add without a uv config set feature.

tlambert03 commented 1 day ago

that would be cool. I guess the partial "mismatch" there is that the exclude-newer = ... line that would be added to the config section really doesn't have any association with the specific package that was added with uv add. And if someone wanted to "repin" the exclude-newer date to the current date, they would need to pick an existing package to re-add it just so that they could add the --exclude-newer flag, right? Do you agree that it's a bit of a conceptual mismatch?

zanieb commented 1 day ago

I don't think uv add --exclude-newer applies the exclusion to a single package — I think that option is global to the resolution. It's possible the behavior is different when we're reading a previous resolution from the lockfile, but I'm not sure.

zanieb commented 1 day ago

cc @charliermarsh who is likely to know how that interacts

tlambert03 commented 1 day ago

I don't think uv add --exclude-newer applies the exclusion to a single package — I think that option is global to the resolution.

that's exactly my point. and that's why i'm suggesting that it would be a little bit of an awkward/misleading solution