mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
Use file path for detecting package root (#18914)
Ref: https://github.com/astral-sh/ruff/pull/18910#discussion_r2163847956
This commit is contained in:
parent
66fc7c8fc0
commit
2c4c015f74
1 changed files with 12 additions and 7 deletions
|
@ -81,13 +81,18 @@ pub(crate) fn check(
|
|||
return DiagnosticsMap::default();
|
||||
}
|
||||
|
||||
let package = detect_package_root(
|
||||
document_path
|
||||
.parent()
|
||||
.expect("a path to a document should have a parent path"),
|
||||
&settings.linter.namespace_packages,
|
||||
)
|
||||
.map(PackageRoot::root);
|
||||
let file_path = query.file_path();
|
||||
let package = if let Some(file_path) = &file_path {
|
||||
detect_package_root(
|
||||
file_path
|
||||
.parent()
|
||||
.expect("a path to a document should have a parent path"),
|
||||
&settings.linter.namespace_packages,
|
||||
)
|
||||
.map(PackageRoot::root)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let source_type = query.source_type();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue