Skip to content

Commit 3f5a671

Browse files
committed
Allow self-depedencies in the dev section
1 parent 80e76f6 commit 3f5a671

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

crates/uv/src/commands/project/add.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,13 @@ pub(crate) async fn add(
341341
};
342342

343343
// If any of the requirements are self-dependencies, bail.
344-
if matches!(
345-
dependency_type,
346-
DependencyType::Production | DependencyType::Dev
347-
) {
344+
if matches!(dependency_type, DependencyType::Production) {
348345
if let Target::Project(project, _) = &target {
349346
if let Some(project_name) = project.project_name() {
350347
for requirement in &requirements {
351348
if requirement.name == *project_name {
352349
bail!(
353-
"Requirement name `{}` matches project name `{}`, but self-dependencies are not permitted. If your project name (`{}`) is shadowing that of a third-party dependency, consider renaming the project.",
350+
"Requirement name `{}` matches project name `{}`, but self-dependencies are not permitted without the `--dev` or `--optional` flags. If your project name (`{}`) is shadowing that of a third-party dependency, consider renaming the project.",
354351
requirement.name.cyan(),
355352
project_name.cyan(),
356353
project_name.cyan(),

crates/uv/tests/edit.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4959,7 +4959,7 @@ fn add_self() -> Result<()> {
49594959
----- stdout -----
49604960
49614961
----- stderr -----
4962-
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
4962+
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted without the `--dev` or `--optional` flags. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
49634963
"###);
49644964

49654965
let pyproject_toml = context.temp_dir.child("pyproject.toml");
@@ -5023,12 +5023,16 @@ fn add_self() -> Result<()> {
50235023

50245024
// And recursive development dependencies
50255025
uv_snapshot!(context.filters(), context.add().arg("anyio[types]").arg("--dev"), @r###"
5026-
success: false
5027-
exit_code: 2
5026+
success: true
5027+
exit_code: 0
50285028
----- stdout -----
50295029
50305030
----- stderr -----
5031-
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
5031+
Resolved 2 packages in [TIME]
5032+
Prepared 1 package in [TIME]
5033+
Uninstalled 1 package in [TIME]
5034+
Installed 1 package in [TIME]
5035+
~ anyio==0.1.0 (from file://[TEMP_DIR]/)
50325036
"###);
50335037

50345038
let pyproject_toml = context.read("pyproject.toml");
@@ -5054,6 +5058,11 @@ fn add_self() -> Result<()> {
50545058
requires = ["setuptools>=42"]
50555059
build-backend = "setuptools.build_meta"
50565060
5061+
[tool.uv]
5062+
dev-dependencies = [
5063+
"anyio[types]",
5064+
]
5065+
50575066
[tool.uv.sources]
50585067
anyio = { workspace = true }
50595068
"###

0 commit comments

Comments
 (0)