mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-23 09:19:58 +00:00
[ty] Remove mentions of VS Code from server logs (#21155)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
6ddfb51d71
commit
e2e83acd2f
6 changed files with 50 additions and 37 deletions
|
|
@ -131,9 +131,7 @@ impl Options {
|
|||
ValueSource::File(path) => PythonVersionSource::ConfigFile(
|
||||
PythonVersionFileSource::new(path.clone(), ranged_version.range()),
|
||||
),
|
||||
ValueSource::PythonVSCodeExtension => {
|
||||
PythonVersionSource::PythonVSCodeExtension
|
||||
}
|
||||
ValueSource::Editor => PythonVersionSource::Editor,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -153,7 +151,7 @@ impl Options {
|
|||
ValueSource::File(path) => {
|
||||
SysPrefixPathOrigin::ConfigFileSetting(path.clone(), python_path.range())
|
||||
}
|
||||
ValueSource::PythonVSCodeExtension => SysPrefixPathOrigin::PythonVSCodeExtension,
|
||||
ValueSource::Editor => SysPrefixPathOrigin::Editor,
|
||||
};
|
||||
|
||||
Some(PythonEnvironment::new(
|
||||
|
|
@ -819,8 +817,8 @@ impl Rules {
|
|||
ValueSource::File(_) => LintSource::File,
|
||||
ValueSource::Cli => LintSource::Cli,
|
||||
|
||||
ValueSource::PythonVSCodeExtension => {
|
||||
unreachable!("Can't configure rules from the Python VSCode extension")
|
||||
ValueSource::Editor => {
|
||||
unreachable!("Can't configure rules from the user's editor")
|
||||
}
|
||||
};
|
||||
if let Ok(severity) = Severity::try_from(**level) {
|
||||
|
|
@ -957,7 +955,7 @@ fn build_include_filter(
|
|||
SubDiagnosticSeverity::Info,
|
||||
"The pattern was specified on the CLI",
|
||||
)),
|
||||
ValueSource::PythonVSCodeExtension => unreachable!("Can't configure includes from the Python VSCode extension"),
|
||||
ValueSource::Editor => unreachable!("Can't configure includes from the user's editor"),
|
||||
}
|
||||
})?;
|
||||
}
|
||||
|
|
@ -1040,8 +1038,8 @@ fn build_exclude_filter(
|
|||
SubDiagnosticSeverity::Info,
|
||||
"The pattern was specified on the CLI",
|
||||
)),
|
||||
ValueSource::PythonVSCodeExtension => unreachable!(
|
||||
"Can't configure excludes from the Python VSCode extension"
|
||||
ValueSource::Editor => unreachable!(
|
||||
"Can't configure excludes from the user's editor"
|
||||
)
|
||||
}
|
||||
})?;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@ pub enum ValueSource {
|
|||
/// long argument (`--extra-paths`) or `--config key=value`.
|
||||
Cli,
|
||||
|
||||
/// The value comes from an LSP client configuration.
|
||||
PythonVSCodeExtension,
|
||||
/// The value comes from the user's editor,
|
||||
/// while it's left open if specified as a setting
|
||||
/// or if the value was auto-discovered by the editor
|
||||
/// (e.g., the Python environment)
|
||||
Editor,
|
||||
}
|
||||
|
||||
impl ValueSource {
|
||||
|
|
@ -37,7 +40,7 @@ impl ValueSource {
|
|||
match self {
|
||||
ValueSource::File(path) => Some(&**path),
|
||||
ValueSource::Cli => None,
|
||||
ValueSource::PythonVSCodeExtension => None,
|
||||
ValueSource::Editor => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,11 +140,7 @@ impl<T> RangedValue<T> {
|
|||
}
|
||||
|
||||
pub fn python_extension(value: T) -> Self {
|
||||
Self::with_range(
|
||||
value,
|
||||
ValueSource::PythonVSCodeExtension,
|
||||
TextRange::default(),
|
||||
)
|
||||
Self::with_range(value, ValueSource::Editor, TextRange::default())
|
||||
}
|
||||
|
||||
pub fn with_range(value: T, source: ValueSource, range: TextRange) -> Self {
|
||||
|
|
@ -368,7 +367,7 @@ impl RelativePathBuf {
|
|||
}
|
||||
|
||||
pub fn python_extension(path: impl AsRef<SystemPath>) -> Self {
|
||||
Self::new(path, ValueSource::PythonVSCodeExtension)
|
||||
Self::new(path, ValueSource::Editor)
|
||||
}
|
||||
|
||||
/// Returns the relative path as specified by the user.
|
||||
|
|
@ -398,7 +397,7 @@ impl RelativePathBuf {
|
|||
pub fn absolute(&self, project_root: &SystemPath, system: &dyn System) -> SystemPathBuf {
|
||||
let relative_to = match &self.0.source {
|
||||
ValueSource::File(_) => project_root,
|
||||
ValueSource::Cli | ValueSource::PythonVSCodeExtension => system.current_directory(),
|
||||
ValueSource::Cli | ValueSource::Editor => system.current_directory(),
|
||||
};
|
||||
|
||||
SystemPath::absolute(&self.0, relative_to)
|
||||
|
|
@ -454,7 +453,7 @@ impl RelativeGlobPattern {
|
|||
) -> Result<AbsolutePortableGlobPattern, PortableGlobError> {
|
||||
let relative_to = match &self.0.source {
|
||||
ValueSource::File(_) => project_root,
|
||||
ValueSource::Cli | ValueSource::PythonVSCodeExtension => system.current_directory(),
|
||||
ValueSource::Cli | ValueSource::Editor => system.current_directory(),
|
||||
};
|
||||
|
||||
let pattern = PortableGlobPattern::parse(&self.0, kind)?;
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ pub fn add_inferred_python_version_hint_to_diagnostic(
|
|||
or in a configuration file",
|
||||
);
|
||||
}
|
||||
crate::PythonVersionSource::PythonVSCodeExtension => {
|
||||
crate::PythonVersionSource::Editor => {
|
||||
diagnostic.info(format_args!(
|
||||
"Python {version} was assumed when {action} \
|
||||
because it's the version of the selected Python interpreter in the VS Code Python extension",
|
||||
because it's the version of the selected Python interpreter in your editor",
|
||||
));
|
||||
}
|
||||
crate::PythonVersionSource::InstallationDirectoryLayout {
|
||||
|
|
|
|||
|
|
@ -113,8 +113,11 @@ pub enum PythonVersionSource {
|
|||
/// long argument (`--extra-paths`) or `--config key=value`.
|
||||
Cli,
|
||||
|
||||
/// The value comes from the Python VS Code extension (the selected interpreter).
|
||||
PythonVSCodeExtension,
|
||||
/// The value comes from the user's editor,
|
||||
/// while it's left open if specified as a setting
|
||||
/// or if the value was auto-discovered by the editor
|
||||
/// (e.g., the Python environment)
|
||||
Editor,
|
||||
|
||||
/// We fell back to a default value because the value was not specified via the CLI or a config file.
|
||||
#[default]
|
||||
|
|
|
|||
|
|
@ -111,6 +111,12 @@ impl SitePackagesPaths {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SitePackagesPaths {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_list().entries(self.0.iter()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> From<[SystemPathBuf; N]> for SitePackagesPaths {
|
||||
fn from(paths: [SystemPathBuf; N]) -> Self {
|
||||
Self(IndexSet::from(paths))
|
||||
|
|
@ -543,7 +549,7 @@ System site-packages will not be used for module resolution.",
|
|||
}
|
||||
|
||||
tracing::debug!(
|
||||
"Resolved site-packages directories for this virtual environment are: {site_packages_directories:?}"
|
||||
"Resolved site-packages directories for this virtual environment are: {site_packages_directories}"
|
||||
);
|
||||
Ok(site_packages_directories)
|
||||
}
|
||||
|
|
@ -823,7 +829,7 @@ impl SystemEnvironment {
|
|||
)?;
|
||||
|
||||
tracing::debug!(
|
||||
"Resolved site-packages directories for this environment are: {site_packages_directories:?}"
|
||||
"Resolved site-packages directories for this environment are: {site_packages_directories}"
|
||||
);
|
||||
Ok(site_packages_directories)
|
||||
}
|
||||
|
|
@ -1567,8 +1573,8 @@ pub enum SysPrefixPathOrigin {
|
|||
ConfigFileSetting(Arc<SystemPathBuf>, Option<TextRange>),
|
||||
/// The `sys.prefix` path came from a `--python` CLI flag
|
||||
PythonCliFlag,
|
||||
/// The selected interpreter in the VS Code's Python extension.
|
||||
PythonVSCodeExtension,
|
||||
/// The selected interpreter in the user's editor.
|
||||
Editor,
|
||||
/// The `sys.prefix` path came from the `VIRTUAL_ENV` environment variable
|
||||
VirtualEnvVar,
|
||||
/// The `sys.prefix` path came from the `CONDA_PREFIX` environment variable
|
||||
|
|
@ -1590,7 +1596,7 @@ impl SysPrefixPathOrigin {
|
|||
Self::LocalVenv | Self::VirtualEnvVar => true,
|
||||
Self::ConfigFileSetting(..)
|
||||
| Self::PythonCliFlag
|
||||
| Self::PythonVSCodeExtension
|
||||
| Self::Editor
|
||||
| Self::DerivedFromPyvenvCfg
|
||||
| Self::CondaPrefixVar => false,
|
||||
}
|
||||
|
|
@ -1602,9 +1608,7 @@ impl SysPrefixPathOrigin {
|
|||
/// the `sys.prefix` directory, e.g. the `--python` CLI flag.
|
||||
pub(crate) const fn must_point_directly_to_sys_prefix(&self) -> bool {
|
||||
match self {
|
||||
Self::PythonCliFlag | Self::ConfigFileSetting(..) | Self::PythonVSCodeExtension => {
|
||||
false
|
||||
}
|
||||
Self::PythonCliFlag | Self::ConfigFileSetting(..) | Self::Editor => false,
|
||||
Self::VirtualEnvVar
|
||||
| Self::CondaPrefixVar
|
||||
| Self::DerivedFromPyvenvCfg
|
||||
|
|
@ -1622,9 +1626,7 @@ impl std::fmt::Display for SysPrefixPathOrigin {
|
|||
Self::CondaPrefixVar => f.write_str("`CONDA_PREFIX` environment variable"),
|
||||
Self::DerivedFromPyvenvCfg => f.write_str("derived `sys.prefix` path"),
|
||||
Self::LocalVenv => f.write_str("local virtual environment"),
|
||||
Self::PythonVSCodeExtension => {
|
||||
f.write_str("selected interpreter in the VS Code Python extension")
|
||||
}
|
||||
Self::Editor => f.write_str("selected interpreter in your editor"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2377,4 +2379,15 @@ mod tests {
|
|||
assert_eq!(&pyvenv_cfg[version.1], version.0);
|
||||
assert_eq!(parsed.implementation, PythonImplementation::PyPy);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn site_packages_paths_display() {
|
||||
let paths = SitePackagesPaths::default();
|
||||
assert_eq!(paths.to_string(), "[]");
|
||||
|
||||
let mut paths = SitePackagesPaths::default();
|
||||
paths.insert(SystemPathBuf::from("/path/to/site/packages"));
|
||||
|
||||
assert_eq!(paths.to_string(), r#"["/path/to/site/packages"]"#);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ impl WorkspaceOptions {
|
|||
|
||||
if let Some(python) = &overrides.fallback_python {
|
||||
tracing::debug!(
|
||||
"Using the Python environment selected in the VS Code Python extension \
|
||||
"Using the Python environment selected in your editor \
|
||||
in case the configuration doesn't specify a Python environment: {python}",
|
||||
python = python.path()
|
||||
);
|
||||
|
|
@ -221,7 +221,7 @@ impl WorkspaceOptions {
|
|||
|
||||
if let Some(version) = &overrides.fallback_python_version {
|
||||
tracing::debug!(
|
||||
"Using the Python version selected in the VS Code Python extension: {version} \
|
||||
"Using the Python version selected in your editor: {version} \
|
||||
in case the configuration doesn't specify a Python version",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue