mirror of https://github.com/astral-sh/ruff
Add some user-visible logging when pyproject.toml fails to parse
This commit is contained in:
parent
9bf8a0d0f1
commit
0c110bcecf
|
|
@ -130,9 +130,7 @@ impl CheckKind {
|
||||||
CheckKind::FStringMissingPlaceholders => {
|
CheckKind::FStringMissingPlaceholders => {
|
||||||
"f-string without any placeholders".to_string()
|
"f-string without any placeholders".to_string()
|
||||||
}
|
}
|
||||||
CheckKind::IfTuple => {
|
CheckKind::IfTuple => "If test is a tuple, which is always `True`".to_string(),
|
||||||
"If test is a tuple, which is always `True`".to_string()
|
|
||||||
}
|
|
||||||
CheckKind::ImportStarUsage => "Unable to detect undefined names".to_string(),
|
CheckKind::ImportStarUsage => "Unable to detect undefined names".to_string(),
|
||||||
CheckKind::LineTooLong => "Line too long".to_string(),
|
CheckKind::LineTooLong => "Line too long".to_string(),
|
||||||
CheckKind::RaiseNotImplemented => {
|
CheckKind::RaiseNotImplemented => {
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,20 @@ pub fn load_config<'a>(paths: impl IntoIterator<Item = &'a Path>) -> Result<(Pat
|
||||||
match find_project_root(paths) {
|
match find_project_root(paths) {
|
||||||
Some(project_root) => match find_pyproject_toml(&project_root) {
|
Some(project_root) => match find_pyproject_toml(&project_root) {
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
|
debug!("Found pyproject.toml at: {}", path.to_string_lossy());
|
||||||
match parse_pyproject_toml(&path) {
|
match parse_pyproject_toml(&path) {
|
||||||
Ok(pyproject) => {
|
Ok(pyproject) => {
|
||||||
debug!("Found pyproject.toml at: {}", path.to_string_lossy());
|
|
||||||
let config = pyproject
|
let config = pyproject
|
||||||
.tool
|
.tool
|
||||||
.and_then(|tool| tool.ruff)
|
.and_then(|tool| tool.ruff)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
Ok((project_root, config))
|
Ok((project_root, config))
|
||||||
},
|
}
|
||||||
Err(_) => Ok(Default::default())
|
Err(e) => {
|
||||||
|
println!("Failed to load pyproject.toml: {:?}", e);
|
||||||
|
println!("Falling back to default configuration...");
|
||||||
|
Ok(Default::default())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Ok(Default::default()),
|
None => Ok(Default::default()),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue