[ty] Fix some configuration panics in the LSP (#22040)
## Summary This is a revival of https://github.com/astral-sh/ruff/pull/21047 now that we have a reproducer again. * Fixes https://github.com/astral-sh/ty/issues/2031 * Fixes https://github.com/astral-sh/ty/issues/859 ## Test Plan e2e test from @zanieb --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
@@ -163,6 +163,17 @@ impl Default for PythonVersionWithSource {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Copy, Clone, get_size2::GetSize)]
|
||||
pub enum MisconfigurationMode {
|
||||
/// Settings Failure Is Not An Error.
|
||||
///
|
||||
/// This is used by the default database, which we are incentivized to make infallible,
|
||||
/// while still trying to "do our best" to set things up properly where we can.
|
||||
UseDefault,
|
||||
/// Settings Failure Is An Error.
|
||||
Fail,
|
||||
}
|
||||
|
||||
/// Configures the search paths for module resolution.
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct SearchPathSettings {
|
||||
@@ -187,6 +198,9 @@ pub struct SearchPathSettings {
|
||||
/// We should ideally only ever use this for things like goto-definition,
|
||||
/// where typeshed isn't the right answer.
|
||||
pub real_stdlib_path: Option<SystemPathBuf>,
|
||||
|
||||
/// How to handle apparent misconfiguration
|
||||
pub misconfiguration_mode: MisconfigurationMode,
|
||||
}
|
||||
|
||||
impl SearchPathSettings {
|
||||
@@ -204,6 +218,7 @@ impl SearchPathSettings {
|
||||
custom_typeshed: None,
|
||||
site_packages_paths: vec![],
|
||||
real_stdlib_path: None,
|
||||
misconfiguration_mode: MisconfigurationMode::Fail,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user