mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Add target_version
to formatter options (#9220)
This commit is contained in:
parent
ef4bd8d5ff
commit
8cb7950102
21 changed files with 103 additions and 10 deletions
|
@ -175,6 +175,14 @@ impl Configuration {
|
|||
let formatter = FormatterSettings {
|
||||
exclude: FilePatternSet::try_from_iter(format.exclude.unwrap_or_default())?,
|
||||
preview: format_preview,
|
||||
target_version: match target_version {
|
||||
PythonVersion::Py37 => ruff_python_formatter::PythonVersion::Py37,
|
||||
PythonVersion::Py38 => ruff_python_formatter::PythonVersion::Py38,
|
||||
PythonVersion::Py39 => ruff_python_formatter::PythonVersion::Py39,
|
||||
PythonVersion::Py310 => ruff_python_formatter::PythonVersion::Py310,
|
||||
PythonVersion::Py311 => ruff_python_formatter::PythonVersion::Py311,
|
||||
PythonVersion::Py312 => ruff_python_formatter::PythonVersion::Py312,
|
||||
},
|
||||
line_width: self
|
||||
.line_length
|
||||
.map_or(format_defaults.line_width, |length| {
|
||||
|
|
|
@ -117,6 +117,7 @@ impl FileResolverSettings {
|
|||
pub struct FormatterSettings {
|
||||
pub exclude: FilePatternSet,
|
||||
pub preview: PreviewMode,
|
||||
pub target_version: ruff_python_formatter::PythonVersion,
|
||||
|
||||
pub line_width: LineWidth,
|
||||
|
||||
|
@ -157,6 +158,7 @@ impl FormatterSettings {
|
|||
};
|
||||
|
||||
PyFormatOptions::from_source_type(source_type)
|
||||
.with_target_version(self.target_version)
|
||||
.with_indent_style(self.indent_style)
|
||||
.with_indent_width(self.indent_width)
|
||||
.with_quote_style(self.quote_style)
|
||||
|
@ -175,6 +177,7 @@ impl Default for FormatterSettings {
|
|||
|
||||
Self {
|
||||
exclude: FilePatternSet::default(),
|
||||
target_version: default_options.target_version(),
|
||||
preview: PreviewMode::Disabled,
|
||||
line_width: default_options.line_width(),
|
||||
line_ending: LineEnding::Auto,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue