1 parent 931a19f commit 4d4700dCopy full SHA for 4d4700d
1 file changed
crates/ruff_server/src/lint.rs
@@ -81,13 +81,18 @@ pub(crate) fn check(
81
return DiagnosticsMap::default();
82
}
83
84
- let package = detect_package_root(
85
- document_path
86
- .parent()
87
- .expect("a path to a document should have a parent path"),
88
- &settings.linter.namespace_packages,
89
- )
90
- .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,
91
+ )
92
+ .map(PackageRoot::root)
93
+ } else {
94
+ None
95
+ };
96
97
let source_type = query.source_type();
98
0 commit comments