mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:23 +00:00
Use ast::PythonVersion
internally in the formatter and linter (#16170)
## Summary This PR updates the formatter and linter to use the `PythonVersion` struct from the `ruff_python_ast` crate internally. While this doesn't remove the need for the `linter::PythonVersion` enum, it does remove the `formatter::PythonVersion` enum and limits the use in the linter to deserializing from CLI arguments and config files and moves most of the remaining methods to the `ast::PythonVersion` struct. ## Test Plan Existing tests, with some inputs and outputs updated to reflect the new (de)serialization format. I think these are test-specific and shouldn't affect any external (de)serialization. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
0868e73d2c
commit
a9efdea113
153 changed files with 456 additions and 539 deletions
|
@ -10,7 +10,7 @@ use ruff_db::files::{File, Files};
|
|||
use ruff_db::system::{OsSystem, System, SystemPathBuf};
|
||||
use ruff_db::vendored::{VendoredFileSystem, VendoredFileSystemBuilder};
|
||||
use ruff_db::{Db as SourceDb, Upcast};
|
||||
use ruff_python_ast::python_version::PythonVersion;
|
||||
use ruff_python_ast::PythonVersion;
|
||||
|
||||
static EMPTY_VENDORED: std::sync::LazyLock<VendoredFileSystem> = std::sync::LazyLock::new(|| {
|
||||
let mut builder = VendoredFileSystemBuilder::new(CompressionMethod::Stored);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use ruff_linter::display_settings;
|
||||
use ruff_linter::settings::types::{ExtensionMapping, FilePatternSet, PreviewMode, PythonVersion};
|
||||
use ruff_linter::settings::types::{ExtensionMapping, FilePatternSet, PreviewMode};
|
||||
use ruff_macros::CacheKey;
|
||||
use ruff_python_ast::PythonVersion;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
|
@ -24,7 +25,7 @@ impl fmt::Display for AnalyzeSettings {
|
|||
fields = [
|
||||
self.exclude,
|
||||
self.preview,
|
||||
self.target_version | debug,
|
||||
self.target_version,
|
||||
self.detect_string_imports,
|
||||
self.extension | debug,
|
||||
self.include_dependencies | debug,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue