Skip to content

Comments

Allow explicit values with uv version --bump#16555

Merged
Gankra merged 14 commits intoastral-sh:mainfrom
terror:allow-bump-specific-version
Nov 11, 2025
Merged

Allow explicit values with uv version --bump#16555
Gankra merged 14 commits intoastral-sh:mainfrom
terror:allow-bump-specific-version

Conversation

@terror
Copy link
Contributor

@terror terror commented Nov 2, 2025

Resolves #16427

This PR updates uv version --bump so you can pin the exact number you’re targeting, i.e. --bump patch=10 or --bump dev=42. The command-line interface now parses those component=value flags, and the bump logic actually sets the version to the number you asked for.

`stable`, `alpha`, `beta`, `rc`, `post`, and `dev`. When provided more than once, the components
will be applied in order, from largest (`major`) to smallest (`dev`).

You can optionally provide a numeric value with `--bump <component>=<value>` to set the resulting
Copy link
Member

Choose a reason for hiding this comment

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

As a note, I don't think this belongs in the "guide" long-term — this kind of less common functionality belongs in the "concepts" section but we don't have one for uv version yet.

I guess it'd be a "Project version" section in https://docs.astral.sh/uv/concepts/projects/config/ ? We should open an issue to track that work and ref this comment.

Comment on lines 736 to 737
let value =
match value {
Copy link
Contributor

Choose a reason for hiding this comment

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

aside: i am perplexed by rustfmt selecting this

Copy link
Contributor Author

@terror terror Nov 8, 2025

Choose a reason for hiding this comment

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

Looked into this and it seems to be because of the multiline RHS expression, I kinda like this better:

let value = match value {
    Some(raw) if raw.is_empty() => {
        return Err("`--bump` values cannot be empty".to_string());
    }
    Some(raw) => Some(
        raw.parse::<u64>()
            .map_err(|_| format!("invalid numeric value `{raw}` for `--bump {name}`"))?,
    ),
    None => None,
};

(no rustfmt interference here 😅)

@Gankra
Copy link
Contributor

Gankra commented Nov 8, 2025

(Btw the actual clap parser work is rad, and thank you for jumping on this!)

Comment on lines +985 to +992
pyproject_toml.write_str(
r#"
[project]
name = "myproject"
version = "0.1.0.dev4"
requires-python = ">=3.12"
"#,
)?;
Copy link
Contributor Author

@terror terror Nov 8, 2025

Choose a reason for hiding this comment

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

aside: There are a few other places we manually dedent like this (and then some places we don't dedent at all). We may want to pull in something like indoc and use it everywhere to be consistent.

@terror terror requested a review from Gankra November 11, 2025 00:19
Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

Nice, looks good!

Comment on lines 733 to 740
} else {
full.post = Some(1);
// Either bump or set to 1
if let Some(post) = &mut full.post {
*post += 1;
} else {
full.post = Some(1);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This could technically be made into an else-if but it's consistent with the other block to not, so on balance this is probably better..?

@Gankra Gankra merged commit 63ab247 into astral-sh:main Nov 11, 2025
100 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 14, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.8` -> `0.9.9` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.9.9`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#099)

[Compare Source](astral-sh/uv@0.9.8...0.9.9)

Released on 2025-11-12.

##### Deprecations

- Deprecate use of `--project` in `uv init` ([#&#8203;16674](astral-sh/uv#16674))

##### Enhancements

- Add iOS support to Python interpreter discovery ([#&#8203;16686](astral-sh/uv#16686))
- Reject ambiguously parsed URLs ([#&#8203;16622](astral-sh/uv#16622))
- Allow explicit values in `uv version --bump` ([#&#8203;16555](astral-sh/uv#16555))
- Warn on use of managed pre-release Python versions when a stable version is available ([#&#8203;16619](astral-sh/uv#16619))
- Allow signing trampolines on Windows by using `.rcdata` to store metadata ([#&#8203;15068](astral-sh/uv#15068))
- Add `--only-emit-workspace` and similar variants to `uv export` ([#&#8203;16681](astral-sh/uv#16681))

##### Preview features

- Add `uv workspace dir` command ([#&#8203;16678](astral-sh/uv#16678))
- Add `uv workspace metadata` command ([#&#8203;16516](astral-sh/uv#16516))

##### Configuration

- Add `UV_NO_DEFAULT_GROUPS` environment variable ([#&#8203;16645](astral-sh/uv#16645))

##### Bug fixes

- Remove `torch-model-archiver` and `torch-tb-profiler` from PyTorch backend ([#&#8203;16655](astral-sh/uv#16655))
- Fix Pixi environment detection ([#&#8203;16585](astral-sh/uv#16585))

##### Documentation

- Fix `CMD` path in FastAPI Dockerfile ([#&#8203;16701](astral-sh/uv#16701))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNzMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting a custom value for uv version --bump

3 participants