mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Add Python version support to ruff analyze CLI (#13426)
This commit is contained in:
parent
2823487bf8
commit
ff11db61b4
7 changed files with 30 additions and 6 deletions
|
@ -16,7 +16,10 @@ pub struct ModuleDb {
|
|||
|
||||
impl ModuleDb {
|
||||
/// Initialize a [`ModuleDb`] from the given source root.
|
||||
pub fn from_src_roots(mut src_roots: impl Iterator<Item = SystemPathBuf>) -> Result<Self> {
|
||||
pub fn from_src_roots(
|
||||
mut src_roots: impl Iterator<Item = SystemPathBuf>,
|
||||
target_version: PythonVersion,
|
||||
) -> Result<Self> {
|
||||
let search_paths = {
|
||||
// Use the first source root.
|
||||
let src_root = src_roots
|
||||
|
@ -37,7 +40,7 @@ impl ModuleDb {
|
|||
Program::from_settings(
|
||||
&db,
|
||||
&ProgramSettings {
|
||||
target_version: PythonVersion::default(),
|
||||
target_version,
|
||||
search_paths,
|
||||
},
|
||||
)?;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_linter::display_settings;
|
||||
use ruff_linter::settings::types::{ExtensionMapping, FilePatternSet, PreviewMode};
|
||||
use ruff_linter::settings::types::{ExtensionMapping, FilePatternSet, PreviewMode, PythonVersion};
|
||||
use ruff_macros::CacheKey;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
|
@ -9,6 +9,7 @@ use std::path::PathBuf;
|
|||
pub struct AnalyzeSettings {
|
||||
pub exclude: FilePatternSet,
|
||||
pub preview: PreviewMode,
|
||||
pub target_version: PythonVersion,
|
||||
pub detect_string_imports: bool,
|
||||
pub include_dependencies: BTreeMap<PathBuf, (PathBuf, Vec<String>)>,
|
||||
pub extension: ExtensionMapping,
|
||||
|
@ -23,6 +24,7 @@ impl fmt::Display for AnalyzeSettings {
|
|||
fields = [
|
||||
self.exclude,
|
||||
self.preview,
|
||||
self.target_version | debug,
|
||||
self.detect_string_imports,
|
||||
self.extension | debug,
|
||||
self.include_dependencies | debug,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue