mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
[ty] Add search paths info to unresolved import diagnostics (#20040)
Fixes https://github.com/astral-sh/ty/issues/457 --------- Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
136abace92
commit
73720c73be
11 changed files with 111 additions and 7 deletions
|
@ -10,8 +10,7 @@ pub use resolver::{resolve_module, resolve_real_module};
|
|||
use ruff_db::system::SystemPath;
|
||||
|
||||
use crate::Db;
|
||||
use crate::module_resolver::resolver::{ModuleResolveMode, search_paths};
|
||||
use resolver::SearchPathIterator;
|
||||
pub(crate) use resolver::{ModuleResolveMode, SearchPathIterator, search_paths};
|
||||
|
||||
mod list;
|
||||
mod module;
|
||||
|
|
|
@ -700,6 +700,25 @@ impl SearchPath {
|
|||
SearchPathInner::StandardLibraryVendored(_) => "std-vendored",
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a string suitable for describing what kind of search path this is
|
||||
/// in user-facing diagnostics.
|
||||
#[must_use]
|
||||
pub(crate) fn describe_kind(&self) -> &'static str {
|
||||
match *self.0 {
|
||||
SearchPathInner::Extra(_) => {
|
||||
"extra search path specified on the CLI or in your config file"
|
||||
}
|
||||
SearchPathInner::FirstParty(_) => "first-party code",
|
||||
SearchPathInner::StandardLibraryCustom(_) => {
|
||||
"custom stdlib stubs specified on the CLI or in your config file"
|
||||
}
|
||||
SearchPathInner::StandardLibraryReal(_) => "runtime stdlib source code",
|
||||
SearchPathInner::SitePackages(_) => "site-packages",
|
||||
SearchPathInner::Editable(_) => "editable install",
|
||||
SearchPathInner::StandardLibraryVendored(_) => "stdlib typeshed stubs vendored by ty",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<SystemPath> for SearchPath {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue