mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 18:03:03 +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
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"target_version": "py38"}
|
||||
{"target_version": "3.8"}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py311"}
|
||||
{"target_version": "3.11"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py38"}
|
||||
{"target_version": "3.8"}
|
|
@ -1 +1 @@
|
|||
{"preview": "enabled", "target_version": "py310"}
|
||||
{"preview": "enabled", "target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"preview": "enabled", "target_version": "py310"}
|
||||
{"preview": "enabled", "target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py311"}
|
||||
{"target_version": "3.11"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py311"}
|
||||
{"target_version": "3.11"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py311"}
|
||||
{"target_version": "3.11"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py312"}
|
||||
{"target_version": "3.12"}
|
|
@ -1 +1 @@
|
|||
{"preview": "enabled", "target_version": "py311"}
|
||||
{"preview": "enabled", "target_version": "3.11"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"preview": "enabled", "line_width": 79, "target_version": "py310"}
|
||||
{"preview": "enabled", "line_width": 79, "target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py310"}
|
||||
{"target_version": "3.10"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py312"}
|
||||
{"target_version": "3.12"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py313"}
|
||||
{"target_version": "3.13"}
|
|
@ -1 +1 @@
|
|||
{"target_version": "py312"}
|
||||
{"target_version": "3.12"}
|
|
@ -58,8 +58,7 @@ def import_fixture(fixture: Path, fixture_set: str):
|
|||
if "--minimum-version=" in flags:
|
||||
[_, version] = flags.split("--minimum-version=", 1)
|
||||
version = version.split(" ", 1)[0]
|
||||
# Convert 3.10 to py310
|
||||
black_options["target_version"] = f"py{version.strip().replace('.', '')}"
|
||||
black_options["target_version"] = version.strip()
|
||||
|
||||
if "--skip-magic-trailing-comma" in flags:
|
||||
black_options["magic_trailing_comma"] = "ignore"
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
},
|
||||
{
|
||||
"quote_style": "preserve",
|
||||
"target_version": "py312"
|
||||
"target_version": "3.12"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[
|
||||
{
|
||||
"target_version": "py38"
|
||||
"target_version": "3.8"
|
||||
},
|
||||
{
|
||||
"target_version": "py39",
|
||||
"target_version": "3.9",
|
||||
"preview": "enabled"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"target_version": "py39",
|
||||
"target_version": "3.9",
|
||||
"preview": "enabled"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::comments::{
|
|||
pub use crate::context::PyFormatContext;
|
||||
pub use crate::options::{
|
||||
DocstringCode, DocstringCodeLineWidth, MagicTrailingComma, PreviewMode, PyFormatOptions,
|
||||
PythonVersion, QuoteStyle,
|
||||
QuoteStyle,
|
||||
};
|
||||
use crate::range::is_logical_line;
|
||||
pub use crate::shared_traits::{AsFormat, FormattedIter, FormattedIterExt, IntoFormat};
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::str::FromStr;
|
|||
use ruff_formatter::printer::{LineEnding, PrinterOptions, SourceMapGeneration};
|
||||
use ruff_formatter::{FormatOptions, IndentStyle, IndentWidth, LineWidth};
|
||||
use ruff_macros::CacheKey;
|
||||
use ruff_python_ast::PySourceType;
|
||||
use ruff_python_ast::{self as ast, PySourceType};
|
||||
|
||||
/// Resolved options for formatting one individual file. The difference to `FormatterSettings`
|
||||
/// is that `FormatterSettings` stores the settings for multiple files (the entire project, a subdirectory, ..)
|
||||
|
@ -21,7 +21,7 @@ pub struct PyFormatOptions {
|
|||
|
||||
/// The (minimum) Python version used to run the formatted code. This is used
|
||||
/// to determine the supported Python syntax.
|
||||
target_version: PythonVersion,
|
||||
target_version: ast::PythonVersion,
|
||||
|
||||
/// Specifies the indent style:
|
||||
/// * Either a tab
|
||||
|
@ -80,7 +80,7 @@ impl Default for PyFormatOptions {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
source_type: PySourceType::default(),
|
||||
target_version: PythonVersion::default(),
|
||||
target_version: ast::PythonVersion::default(),
|
||||
indent_style: default_indent_style(),
|
||||
line_width: default_line_width(),
|
||||
indent_width: default_indent_width(),
|
||||
|
@ -108,7 +108,7 @@ impl PyFormatOptions {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn target_version(&self) -> PythonVersion {
|
||||
pub const fn target_version(&self) -> ast::PythonVersion {
|
||||
self.target_version
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ impl PyFormatOptions {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_target_version(mut self, target_version: PythonVersion) -> Self {
|
||||
pub fn with_target_version(mut self, target_version: ast::PythonVersion) -> Self {
|
||||
self.target_version = target_version;
|
||||
self
|
||||
}
|
||||
|
@ -468,52 +468,3 @@ where
|
|||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(CacheKey, Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Default)]
|
||||
#[cfg_attr(
|
||||
feature = "serde",
|
||||
derive(serde::Serialize, serde::Deserialize),
|
||||
serde(rename_all = "lowercase")
|
||||
)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum PythonVersion {
|
||||
Py37,
|
||||
Py38,
|
||||
// Make sure to also change the default for `ruff_linter::settings::types::PythonVersion`
|
||||
// when changing the default here.
|
||||
#[default]
|
||||
Py39,
|
||||
Py310,
|
||||
Py311,
|
||||
Py312,
|
||||
Py313,
|
||||
}
|
||||
|
||||
impl PythonVersion {
|
||||
/// Return `true` if the current version supports [PEP 701].
|
||||
///
|
||||
/// [PEP 701]: https://peps.python.org/pep-0701/
|
||||
pub fn supports_pep_701(self) -> bool {
|
||||
self >= Self::Py312
|
||||
}
|
||||
|
||||
pub fn as_tuple(self) -> (u8, u8) {
|
||||
match self {
|
||||
Self::Py37 => (3, 7),
|
||||
Self::Py38 => (3, 8),
|
||||
Self::Py39 => (3, 9),
|
||||
Self::Py310 => (3, 10),
|
||||
Self::Py311 => (3, 11),
|
||||
Self::Py312 => (3, 12),
|
||||
Self::Py313 => (3, 13),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latest() -> Self {
|
||||
Self::Py313
|
||||
}
|
||||
|
||||
pub fn minimal_supported() -> Self {
|
||||
Self::Py37
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use ruff_formatter::{format_args, write, FormatContext, FormatError};
|
||||
use ruff_python_ast::PythonVersion;
|
||||
use ruff_python_ast::{StmtWith, WithItem};
|
||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
@ -14,7 +15,6 @@ use crate::other::with_item::WithItemLayout;
|
|||
use crate::prelude::*;
|
||||
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
|
||||
use crate::statement::suite::SuiteKind;
|
||||
use crate::PythonVersion;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtWith;
|
||||
|
@ -302,7 +302,7 @@ impl<'a> WithItemsLayout<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let can_parenthesize = context.options().target_version() >= PythonVersion::Py39
|
||||
let can_parenthesize = context.options().target_version() >= PythonVersion::PY39
|
||||
|| are_with_items_parenthesized(with, context)?;
|
||||
|
||||
// If the target version doesn't support parenthesized context managers and they aren't
|
||||
|
|
|
@ -26,8 +26,9 @@ fn black_compatibility() {
|
|||
|
||||
let options: PyFormatOptions = if let Ok(options_file) = fs::File::open(&options_path) {
|
||||
let reader = BufReader::new(options_file);
|
||||
serde_json::from_reader(reader)
|
||||
.unwrap_or_else(|_| panic!("Option file {options_path:?} to be a valid Json file"))
|
||||
serde_json::from_reader(reader).unwrap_or_else(|_| {
|
||||
panic!("Expected option file {options_path:?} to be a valid Json file")
|
||||
})
|
||||
} else {
|
||||
PyFormatOptions::from_extension(input_path)
|
||||
};
|
||||
|
@ -180,10 +181,12 @@ fn format() {
|
|||
let mut snapshot = format!("## Input\n{}", CodeFrame::new("python", &content));
|
||||
let options_path = input_path.with_extension("options.json");
|
||||
|
||||
if let Ok(options_file) = fs::File::open(options_path) {
|
||||
if let Ok(options_file) = fs::File::open(&options_path) {
|
||||
let reader = BufReader::new(options_file);
|
||||
let options: Vec<PyFormatOptions> =
|
||||
serde_json::from_reader(reader).expect("Options to be a valid Json file");
|
||||
serde_json::from_reader(reader).unwrap_or_else(|_| {
|
||||
panic!("Expected option file {options_path:?} to be a valid Json file")
|
||||
});
|
||||
|
||||
writeln!(snapshot, "## Outputs").unwrap();
|
||||
|
||||
|
@ -473,7 +476,7 @@ magic-trailing-comma = {magic_trailing_comma:?}
|
|||
docstring-code = {docstring_code:?}
|
||||
docstring-code-line-width = {docstring_code_line_width:?}
|
||||
preview = {preview:?}
|
||||
target_version = {target_version:?}
|
||||
target_version = {target_version}
|
||||
source_type = {source_type:?}"#,
|
||||
indent_style = self.0.indent_style(),
|
||||
indent_width = self.0.indent_width().value(),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -57,7 +56,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -176,7 +175,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -352,7 +351,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -528,7 +527,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -704,7 +703,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -880,7 +879,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -1369,7 +1368,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -2741,7 +2740,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -4113,7 +4112,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -5485,7 +5484,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -6857,7 +6856,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -8222,7 +8221,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -9587,7 +9586,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -10961,7 +10960,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -12326,7 +12325,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = 60
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -13700,7 +13699,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -28,7 +27,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_dynamic_line_width.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -309,7 +308,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -880,7 +879,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -1426,7 +1425,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -1997,7 +1996,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_tab_indentation.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -91,7 +90,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -185,7 +184,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -141,7 +140,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -297,7 +296,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -751,7 +751,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -1551,7 +1551,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_preview.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -39,7 +38,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -81,7 +81,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py312
|
||||
target_version = 3.12
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/string.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -233,7 +232,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -483,7 +482,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -38,7 +37,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -76,7 +75,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -19,7 +18,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -38,7 +37,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -57,7 +56,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -34,7 +33,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -69,7 +68,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -104,7 +103,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/notebook_docstring.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -25,7 +24,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Ipynb
|
||||
```
|
||||
|
||||
|
@ -49,7 +48,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/preview.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -85,7 +84,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -168,7 +167,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/quote_style.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -69,7 +68,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -143,7 +142,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -217,7 +216,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/docstring_code_examples.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -122,7 +121,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -274,7 +273,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Enabled
|
||||
docstring-code-line-width = 88
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/indent.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -82,7 +81,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -161,7 +160,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -240,7 +239,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Stub
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/skip_magic_trailing_comma.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -52,7 +51,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -110,7 +109,7 @@ magic-trailing-comma = Ignore
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py38
|
||||
target_version = 3.8
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -889,7 +889,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/with_39.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -111,7 +110,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/blank_line_after_nested_stub_class.pyi
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -202,7 +201,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Stub
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/blank_line_after_nested_stub_class_eof.pyi
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -36,7 +35,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Stub
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
|
@ -27,7 +26,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -54,7 +53,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
@ -84,7 +83,7 @@ magic-trailing-comma = Respect
|
|||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Disabled
|
||||
target_version = Py39
|
||||
target_version = 3.9
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue