mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
Add --extension
support to the formatter (#9483)
## Summary We added `--extension` to `ruff check`, but it's equally applicable to `ruff format`. Closes https://github.com/astral-sh/ruff/issues/9482. Resolves https://github.com/astral-sh/ruff/discussions/9481. ## Test Plan `cargo test`
This commit is contained in:
parent
d16c4a2d25
commit
3261d16e61
11 changed files with 221 additions and 51 deletions
|
@ -1,7 +1,9 @@
|
|||
use path_absolutize::path_dedot;
|
||||
use ruff_cache::cache_dir;
|
||||
use ruff_formatter::{FormatOptions, IndentStyle, IndentWidth, LineWidth};
|
||||
use ruff_linter::settings::types::{FilePattern, FilePatternSet, SerializationFormat, UnsafeFixes};
|
||||
use ruff_linter::settings::types::{
|
||||
ExtensionMapping, FilePattern, FilePatternSet, SerializationFormat, UnsafeFixes,
|
||||
};
|
||||
use ruff_linter::settings::LinterSettings;
|
||||
use ruff_macros::CacheKey;
|
||||
use ruff_python_ast::PySourceType;
|
||||
|
@ -116,6 +118,7 @@ impl FileResolverSettings {
|
|||
#[derive(CacheKey, Clone, Debug)]
|
||||
pub struct FormatterSettings {
|
||||
pub exclude: FilePatternSet,
|
||||
pub extension: ExtensionMapping,
|
||||
pub preview: PreviewMode,
|
||||
pub target_version: ruff_python_formatter::PythonVersion,
|
||||
|
||||
|
@ -177,6 +180,7 @@ impl Default for FormatterSettings {
|
|||
|
||||
Self {
|
||||
exclude: FilePatternSet::default(),
|
||||
extension: ExtensionMapping::default(),
|
||||
target_version: default_options.target_version(),
|
||||
preview: PreviewMode::Disabled,
|
||||
line_width: default_options.line_width(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue