Skip to content

Fix handling of inline optional dependencies in uv add #7023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/uv-workspace/src/pyproject_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl PyProjectTomlMut {
.doc()?
.entry("optional-dependencies")
.or_insert(Item::Table(Table::new()))
.as_table_mut()
.as_table_like_mut()
.ok_or(Error::MalformedDependencies)?;

let group = optional_dependencies
Expand Down
15 changes: 10 additions & 5 deletions crates/uv/tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,13 +1394,16 @@ fn add_remove_inline_optional() -> Result<()> {
"#})?;

uv_snapshot!(context.filters(), context.add().arg("typing-extensions").arg("--optional=types"), @r###"
success: false
exit_code: 2
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 5 packages in [TIME]
error: Dependencies in `pyproject.toml` are malformed
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ project==0.1.0 (from file://[TEMP_DIR]/)
+ typing-extensions==4.10.0
"###);

let pyproject_toml = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?;
Expand All @@ -1418,7 +1421,7 @@ fn add_remove_inline_optional() -> Result<()> {
optional-dependencies = { io = [
"anyio==3.7.0",
], types = [
"typing-extensions",
"typing-extensions>=4.10.0",
] }

[build-system]
Expand All @@ -1436,11 +1439,13 @@ fn add_remove_inline_optional() -> Result<()> {
----- stderr -----
Resolved 4 packages in [TIME]
Prepared 4 packages in [TIME]
Uninstalled 2 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==3.7.0
+ idna==3.6
+ project==0.1.0 (from file://[TEMP_DIR]/)
~ project==0.1.0 (from file://[TEMP_DIR]/)
+ sniffio==1.3.1
- typing-extensions==4.10.0
"###);

let pyproject_toml = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?;
Expand Down
Loading