Skip to content

Commit 9b40d6b

Browse files
committed
New format for pyproject.toml
1 parent 2c401c4 commit 9b40d6b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

crates/pet-poetry/src/pyproject_toml.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,23 @@ fn parse_contents(contents: &str, file: &Path) -> Option<PyProjectToml> {
6363
}
6464
}
6565
}
66-
trace!("Successfully parsed TOML value: {:?}", value);
67-
name.map(|name| PyProjectToml::new(name, file.into()))
66+
67+
match name {
68+
Some(name) => Some(PyProjectToml::new(name, file.into())),
69+
None => {
70+
trace!(
71+
"Poetry project name not found in {:?}, trying the new format",
72+
file
73+
);
74+
let mut name = None;
75+
if let Some(project) = value.get("project") {
76+
if let Some(name_value) = project.get("name") {
77+
name = name_value.as_str().map(|s| s.to_string());
78+
}
79+
}
80+
name.map(|name| PyProjectToml::new(name, file.into()))
81+
}
82+
}
6883
}
6984
Err(e) => {
7085
error!("Error parsing toml file: {:?}", e);

0 commit comments

Comments
 (0)