[ty] cargo insta test --force-update-snapshots (#22313)

Snapshot tests recently started reporting this warning:

> Snapshot test passes but the existing value is in a legacy format.
> Please run cargo insta test --force-update-snapshots to update to a
> newer format.

This PR is the result of that forced update.

One file (crates/ruff_db/src/diagnostic/render/full.rs) seems to get
corrupted, because it contains strings with unprintable characters that
trigger some bug in cargo-insta. I've manually reverted that file, and
also manually reverted the `input_file:` lines, which we like.
This commit is contained in:
Jack O'Connor
2026-01-05 07:55:47 -08:00
committed by GitHub
parent 6b3de1517a
commit 4712503c6d
897 changed files with 1663 additions and 1926 deletions

View File

@@ -1305,7 +1305,7 @@ mod tests {
settings.add_filter(r"(Panicked at) [^:]+:\d+:\d+", "$1 <location>");
let _s = settings.bind_to_scope();
assert_snapshot!(str::from_utf8(&buf)?, @r"
assert_snapshot!(str::from_utf8(&buf)?, @"
io: test.py: Permission denied
--> test.py:1:1

View File

@@ -4,4 +4,3 @@ source: crates/ruff/src/commands/check.rs
/home/ferris/project/code.py:1:1: E902 Permission denied (os error 13)
/home/ferris/project/notebook.ipynb:1:1: E902 Permission denied (os error 13)
/home/ferris/project/pyproject.toml:1:1: E902 Permission denied (os error 13)

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff/src/version.rs
expression: version
snapshot_kind: text
---
0.0.0

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff/src/version.rs
expression: version
snapshot_kind: text
---
0.0.0 (53b0f5d92 2023-10-19)

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff/src/version.rs
expression: version
snapshot_kind: text
---
0.0.0+24 (53b0f5d92 2023-10-19)

View File

@@ -1,7 +1,6 @@
---
source: crates/ruff/src/version.rs
expression: version
snapshot_kind: text
---
{
"version": "0.0.0",

View File

@@ -132,29 +132,29 @@ fn dependents() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().arg("--direction").arg("dependents").current_dir(&root), @r###"
success: true
exit_code: 0
----- stdout -----
{
"ruff/__init__.py": [],
"ruff/a.py": [],
"ruff/b.py": [
"ruff/a.py"
],
"ruff/c.py": [
"ruff/b.py"
],
"ruff/d.py": [
"ruff/c.py"
],
"ruff/e.py": [
"ruff/d.py"
]
}
assert_cmd_snapshot!(command().arg("--direction").arg("dependents").current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
{
"ruff/__init__.py": [],
"ruff/a.py": [],
"ruff/b.py": [
"ruff/a.py"
],
"ruff/c.py": [
"ruff/b.py"
],
"ruff/d.py": [
"ruff/c.py"
],
"ruff/e.py": [
"ruff/d.py"
]
}
----- stderr -----
"###);
----- stderr -----
"#);
});
Ok(())
@@ -184,21 +184,21 @@ fn string_detection() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
success: true
exit_code: 0
----- stdout -----
{
"ruff/__init__.py": [],
"ruff/a.py": [
"ruff/b.py"
],
"ruff/b.py": [],
"ruff/c.py": []
}
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
{
"ruff/__init__.py": [],
"ruff/a.py": [
"ruff/b.py"
],
"ruff/b.py": [],
"ruff/c.py": []
}
----- stderr -----
"###);
----- stderr -----
"#);
});
insta::with_settings!({
@@ -319,7 +319,7 @@ fn globs() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -340,7 +340,7 @@ fn globs() -> Result<()> {
}
----- stderr -----
"###);
"#);
});
Ok(())
@@ -368,7 +368,7 @@ fn exclude() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -381,7 +381,7 @@ fn exclude() -> Result<()> {
}
----- stderr -----
"###);
"#);
});
Ok(())
@@ -421,7 +421,7 @@ fn wildcard() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -443,7 +443,7 @@ fn wildcard() -> Result<()> {
}
----- stderr -----
"###);
"#);
});
Ok(())
@@ -639,7 +639,7 @@ fn venv() -> Result<()> {
}, {
assert_cmd_snapshot!(
command().args(["--python", "none"]).arg("packages/albatross").current_dir(&root),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -695,7 +695,7 @@ fn notebook_basic() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -708,7 +708,7 @@ fn notebook_basic() -> Result<()> {
}
----- stderr -----
"###);
"#);
});
Ok(())
@@ -765,7 +765,7 @@ fn notebook_with_magic() -> Result<()> {
insta::with_settings!({
filters => INSTA_FILTERS.to_vec(),
}, {
assert_cmd_snapshot!(command().current_dir(&root), @r###"
assert_cmd_snapshot!(command().current_dir(&root), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -778,7 +778,7 @@ fn notebook_with_magic() -> Result<()> {
}
----- stderr -----
"###);
"#);
});
Ok(())

View File

@@ -29,7 +29,7 @@ fn type_checking_imports() -> anyhow::Result<()> {
("ruff/c.py", ""),
])?;
assert_cmd_snapshot!(test.command(), @r###"
assert_cmd_snapshot!(test.command(), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -46,12 +46,12 @@ fn type_checking_imports() -> anyhow::Result<()> {
}
----- stderr -----
"###);
"#);
assert_cmd_snapshot!(
test.command()
.arg("--no-type-checking-imports"),
@r###"
@r#"
success: true
exit_code: 0
----- stdout -----
@@ -65,7 +65,7 @@ fn type_checking_imports() -> anyhow::Result<()> {
}
----- stderr -----
"###
"#
);
Ok(())
@@ -103,7 +103,7 @@ fn type_checking_imports_from_config() -> anyhow::Result<()> {
),
])?;
assert_cmd_snapshot!(test.command(), @r###"
assert_cmd_snapshot!(test.command(), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -117,7 +117,7 @@ fn type_checking_imports_from_config() -> anyhow::Result<()> {
}
----- stderr -----
"###);
"#);
test.write_file(
"ruff.toml",
@@ -127,7 +127,7 @@ fn type_checking_imports_from_config() -> anyhow::Result<()> {
"#,
)?;
assert_cmd_snapshot!(test.command(), @r###"
assert_cmd_snapshot!(test.command(), @r#"
success: true
exit_code: 0
----- stdout -----
@@ -144,7 +144,7 @@ fn type_checking_imports_from_config() -> anyhow::Result<()> {
}
----- stderr -----
"###
"#
);
Ok(())

View File

@@ -51,7 +51,7 @@ fn default_files() -> Result<()> {
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--check"), @r"
.arg("--check"), @"
success: false
exit_code: 1
----- stdout -----
@@ -71,7 +71,7 @@ fn format_warn_stdin_filename_with_files() -> Result<()> {
assert_cmd_snapshot!(test.format_command()
.args(["--isolated", "--stdin-filename", "foo.py"])
.arg("foo.py")
.pass_stdin("foo = 1"), @r"
.pass_stdin("foo = 1"), @"
success: true
exit_code: 0
----- stdout -----
@@ -87,7 +87,7 @@ fn format_warn_stdin_filename_with_files() -> Result<()> {
fn nonexistent_config_file() -> Result<()> {
let test = CliTest::new()?;
assert_cmd_snapshot!(test.format_command()
.args(["--config", "foo.toml", "."]), @r"
.args(["--config", "foo.toml", "."]), @"
success: false
exit_code: 2
----- stdout -----
@@ -111,7 +111,7 @@ fn nonexistent_config_file() -> Result<()> {
fn config_override_rejected_if_invalid_toml() -> Result<()> {
let test = CliTest::new()?;
assert_cmd_snapshot!(test.format_command()
.args(["--config", "foo = bar", "."]), @r"
.args(["--config", "foo = bar", "."]), @"
success: false
exit_code: 2
----- stdout -----
@@ -145,7 +145,7 @@ fn too_many_config_files() -> Result<()> {
.arg("ruff.toml")
.arg("--config")
.arg("ruff2.toml")
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 2
----- stdout -----
@@ -168,7 +168,7 @@ fn config_file_and_isolated() -> Result<()> {
.arg("--isolated")
.arg("--config")
.arg("ruff.toml")
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 2
----- stdout -----
@@ -390,7 +390,7 @@ fn mixed_line_endings() -> Result<()> {
assert_cmd_snapshot!(test.format_command()
.arg("--diff")
.arg("--isolated")
.arg("."), @r"
.arg("."), @"
success: true
exit_code: 0
----- stdout -----
@@ -446,7 +446,7 @@ OTHER = "OTHER"
// Explicitly pass test.py, should be formatted regardless of it being excluded by format.exclude
.arg("test.py")
// Format all other files in the directory, should respect the `exclude` and `format.exclude` options
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 1
----- stdout -----
@@ -469,7 +469,7 @@ fn deduplicate_directory_and_explicit_file() -> Result<()> {
.arg("--check")
.arg(".")
.arg("main.py"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -495,7 +495,7 @@ from module import =
assert_cmd_snapshot!(test.format_command()
.arg("--check")
.arg("--isolated")
.arg("main.py"), @r"
.arg("main.py"), @"
success: false
exit_code: 2
----- stdout -----
@@ -522,7 +522,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--check")
.arg("main.py"), @r"
.arg("main.py"), @"
success: false
exit_code: 1
----- stdout -----
@@ -534,7 +534,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("main.py"), @r"
.arg("main.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -545,7 +545,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("main.py"), @r"
.arg("main.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -614,7 +614,7 @@ fn output_format_notebook() -> Result<()> {
assert_cmd_snapshot!(
test.format_command().args(["--isolated", "--preview", "--check"]).arg(path),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -672,7 +672,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--exit-non-zero-on-format")
.arg("main.py"), @r"
.arg("main.py"), @"
success: false
exit_code: 1
----- stdout -----
@@ -685,7 +685,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--exit-non-zero-on-format")
.arg("main.py"), @r"
.arg("main.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -701,7 +701,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--exit-non-zero-on-fix")
.arg("main.py"), @r"
.arg("main.py"), @"
success: false
exit_code: 1
----- stdout -----
@@ -714,7 +714,7 @@ if __name__ == "__main__":
assert_cmd_snapshot!(test.format_command()
.arg("--isolated")
.arg("--exit-non-zero-on-fix")
.arg("main.py"), @r"
.arg("main.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -771,7 +771,7 @@ OTHER = "OTHER"
// Explicitly pass test.py, should not be formatted because of --force-exclude
.arg("test.py")
// Format all other files in the directory, should respect the `exclude` and `format.exclude` options
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 1
----- stdout -----
@@ -931,7 +931,7 @@ tab-size = 2
.pass_stdin(r"
if True:
pass
"), @r"
"), @"
success: false
exit_code: 2
----- stdout -----
@@ -1144,7 +1144,7 @@ def say_hy(name: str):
assert_cmd_snapshot!(test.format_command()
.arg("--config")
.arg("ruff.toml")
.arg("test.py"), @r"
.arg("test.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -1184,7 +1184,7 @@ def say_hy(name: str):
assert_cmd_snapshot!(test.format_command()
.arg("--config")
.arg("ruff.toml")
.arg("test.py"), @r"
.arg("test.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -1216,7 +1216,7 @@ def say_hy(name: str):
assert_cmd_snapshot!(test.format_command()
.arg("--config")
.arg("ruff.toml")
.arg("test.py"), @r"
.arg("test.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -1246,7 +1246,7 @@ fn test_diff() -> Result<()> {
assert_cmd_snapshot!(
test.format_command().args(["--isolated", "--diff"]).args(paths),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1311,7 +1311,7 @@ fn test_diff_no_change() -> Result<()> {
let paths = [fixtures.join("unformatted.py")];
assert_cmd_snapshot!(
test.format_command().args(["--isolated", "--diff"]).args(paths),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1341,7 +1341,7 @@ fn test_diff_stdin_unformatted() -> Result<()> {
test.format_command()
.args(["--isolated", "--diff", "-", "--stdin-filename", "unformatted.py"])
.pass_stdin(unformatted),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1366,7 +1366,7 @@ fn test_diff_stdin_formatted() -> Result<()> {
let unformatted = fs::read(fixtures.join("formatted.py")).unwrap();
assert_cmd_snapshot!(
test.format_command().args(["--isolated", "--diff", "-"]).pass_stdin(unformatted),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -1873,7 +1873,7 @@ include = ["*.ipy"]
assert_cmd_snapshot!(test.format_command()
.args(["--config", "ruff.toml"])
.args(["--extension", "ipy:ipynb"])
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 2
----- stdout -----
@@ -1938,7 +1938,7 @@ include = ["*.ipy"]
assert_cmd_snapshot!(test.format_command()
.args(["--config", "ruff.toml"])
.args(["--extension", "ipy:ipynb"])
.arg("."), @r"
.arg("."), @"
success: true
exit_code: 0
----- stdout -----
@@ -2021,7 +2021,7 @@ def file2(arg1, arg2,):
assert_cmd_snapshot!(test.format_command()
.args(["--isolated", "--range=1:8-1:15"])
.arg("file1.py")
.arg("file2.py"), @r"
.arg("file2.py"), @"
success: false
exit_code: 2
----- stdout -----
@@ -2068,7 +2068,7 @@ fn range_start_larger_than_end() -> Result<()> {
def foo(arg1, arg2,):
print("Shouldn't format this" )
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -2168,7 +2168,7 @@ fn range_missing_line() -> Result<()> {
def foo(arg1, arg2,):
print("Should format this" )
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -2192,7 +2192,7 @@ fn zero_line_number() -> Result<()> {
def foo(arg1, arg2,):
print("Should format this" )
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -2217,7 +2217,7 @@ fn column_and_line_zero() -> Result<()> {
def foo(arg1, arg2,):
print("Should format this" )
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -2274,7 +2274,7 @@ fn range_formatting_notebook() -> Result<()> {
"nbformat": 4,
"nbformat_minor": 5
}
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -2355,7 +2355,7 @@ fn cookiecutter_globbing() -> Result<()> {
])?;
assert_cmd_snapshot!(test.format_command()
.args(["--isolated", "--diff", "."]), @r"
.args(["--isolated", "--diff", "."]), @"
success: true
exit_code: 0
----- stdout -----
@@ -2374,7 +2374,7 @@ fn stable_output_format_warning() -> Result<()> {
test.format_command()
.args(["--output-format=full", "-"])
.pass_stdin(""),
@r"
@"
success: true
exit_code: 0
----- stdout -----

View File

@@ -39,7 +39,7 @@ inline-quotes = "single"
.arg("ruff.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"a = "abcba".strip("aba")"#), @r"
.pass_stdin(r#"a = "abcba".strip("aba")"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -76,18 +76,18 @@ inline-quotes = "single"
.arg("--config")
.arg("ruff.toml")
.arg("-")
.pass_stdin(r#"a = "abcba".strip("aba")"#), @r"
success: false
exit_code: 1
----- stdout -----
-:1:5: Q000 [*] Double quotes found but single quotes preferred
-:1:5: B005 Using `.strip()` with multi-character strings is misleading
-:1:19: Q000 [*] Double quotes found but single quotes preferred
Found 3 errors.
[*] 2 fixable with the `--fix` option.
.pass_stdin(r#"a = "abcba".strip("aba")"#), @"
success: false
exit_code: 1
----- stdout -----
-:1:5: Q000 [*] Double quotes found but single quotes preferred
-:1:5: B005 Using `.strip()` with multi-character strings is misleading
-:1:19: Q000 [*] Double quotes found but single quotes preferred
Found 3 errors.
[*] 2 fixable with the `--fix` option.
----- stderr -----
");
----- stderr -----
");
Ok(())
}
@@ -110,7 +110,7 @@ inline-quotes = "single"
.arg("--config")
.arg("ruff.toml")
.arg("-")
.pass_stdin(r#"a = "abcba".strip("aba")"#), @r"
.pass_stdin(r#"a = "abcba".strip("aba")"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -150,7 +150,7 @@ inline-quotes = "single"
.arg("--config")
.arg("ruff.toml")
.arg("-")
.pass_stdin(r#"a = "abcba".strip("aba")"#), @r"
.pass_stdin(r#"a = "abcba".strip("aba")"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -220,7 +220,7 @@ OTHER = "OTHER"
// Explicitly pass test.py, should be linted regardless of it being excluded by lint.exclude
.arg("test.py")
// Lint all other files in the directory, should respect the `exclude` and `lint.exclude` options
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 1
----- stdout -----
@@ -259,16 +259,16 @@ exclude = ["main.py"]
.arg(".")
// Explicitly pass main.py, should be linted regardless of it being excluded by lint.exclude
.arg("main.py"),
@r"
success: false
exit_code: 1
----- stdout -----
main.py:1:8: F401 [*] `os` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.
@"
success: false
exit_code: 1
----- stdout -----
main.py:1:8: F401 [*] `os` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.
----- stderr -----
"
----- stderr -----
"
);
Ok(())
@@ -299,7 +299,7 @@ from test import say_hy
if __name__ == "__main__":
say_hy("dear Ruff contributor")
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -340,7 +340,7 @@ max-line-length = 100
_ = "---------------------------------------------------------------------------亜亜亜亜亜亜"
# longer than 100
_ = "---------------------------------------------------------------------------亜亜亜亜亜亜亜亜亜亜亜亜亜亜"
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -381,7 +381,7 @@ from test import say_hy
if __name__ == "__main__":
say_hy("dear Ruff contributor")
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -422,7 +422,7 @@ from test import say_hy
if __name__ == "__main__":
say_hy("dear Ruff contributor")
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -461,7 +461,7 @@ ignore = ["D203", "D212"]
assert_cmd_snapshot!(fixture
.check_command()
.current_dir(fixture.root().join("subdirectory"))
, @r"
, @"
success: true
exit_code: 0
----- stdout -----
@@ -478,7 +478,7 @@ ignore = ["D203", "D212"]
fn nonexistent_config_file() {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.args(["--config", "foo.toml", "."]), @r"
.args(["--config", "foo.toml", "."]), @"
success: false
exit_code: 2
----- stdout -----
@@ -501,7 +501,7 @@ fn nonexistent_config_file() {
fn config_override_rejected_if_invalid_toml() {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.args(["--config", "foo = bar", "."]), @r"
.args(["--config", "foo = bar", "."]), @"
success: false
exit_code: 2
----- stdout -----
@@ -537,7 +537,7 @@ fn too_many_config_files() -> Result<()> {
.arg("ruff.toml")
.arg("--config")
.arg("ruff2.toml")
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 2
----- stdout -----
@@ -556,7 +556,7 @@ fn too_many_config_files() -> Result<()> {
fn extend_passed_via_config_argument() {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.args(["--config", "extend = 'foo.toml'", "."]), @r"
.args(["--config", "extend = 'foo.toml'", "."]), @"
success: false
exit_code: 2
----- stdout -----
@@ -588,17 +588,17 @@ extend = "ruff3.toml"
)?;
assert_cmd_snapshot!(fixture
.check_command(), @r"
success: false
exit_code: 2
----- stdout -----
.check_command(), @"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
ruff failed
Cause: Failed to load extended configuration `[TMP]/ruff3.toml` (`[TMP]/ruff.toml` extends `[TMP]/ruff2.toml` extends `[TMP]/ruff3.toml`)
Cause: Failed to read [TMP]/ruff3.toml
Cause: No such file or directory (os error 2)
");
----- stderr -----
ruff failed
Cause: Failed to load extended configuration `[TMP]/ruff3.toml` (`[TMP]/ruff.toml` extends `[TMP]/ruff2.toml` extends `[TMP]/ruff3.toml`)
Cause: Failed to read [TMP]/ruff3.toml
Cause: No such file or directory (os error 2)
");
Ok(())
}
@@ -627,7 +627,7 @@ extend = "ruff.toml"
assert_cmd_snapshot!(fixture
.check_command(),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -659,7 +659,7 @@ select = [E501]
assert_cmd_snapshot!(
fixture.check_command(),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -688,7 +688,7 @@ fn config_file_and_isolated() -> Result<()> {
.arg("--config")
.arg("ruff.toml")
.arg("--isolated")
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 2
----- stdout -----
@@ -742,7 +742,7 @@ x = "longer_than_90_charactersssssssssssssssssssssssssssssssssssssssssssssssssss
.args(["--config", "lint.extend-select=['E501', 'F841']"])
.args(["--config", "lint.isort.combine-as-imports = false"])
.arg("-")
.pass_stdin(test_code), @r"
.pass_stdin(test_code), @"
success: false
exit_code: 1
----- stdout -----
@@ -761,7 +761,7 @@ fn valid_toml_but_nonexistent_option_provided_via_config_argument() {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.args([".", "--config", "extend-select=['F481']"]), // No such code as F481!
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -788,7 +788,7 @@ fn each_toml_option_requires_a_new_flag_1() {
// commas can't be used to delimit different config overrides;
// you need a new --config flag for each override
.args([".", "--config", "extend-select=['F841'], line-length=90"]),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -819,7 +819,7 @@ fn each_toml_option_requires_a_new_flag_2() {
// spaces *also* can't be used to delimit different config overrides;
// you need a new --config flag for each override
.args([".", "--config", "extend-select=['F841'] line-length=90"]),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -886,7 +886,7 @@ fn value_given_to_table_key_is_not_inline_table_2() {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
.args([".", "--config", r#"lint=123"#]),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -953,7 +953,7 @@ select=["E501"]
.arg("ruff.toml")
.args(["--config", "line-length=110"])
.arg("-")
.pass_stdin(test_code), @r"
.pass_stdin(test_code), @"
success: false
exit_code: 1
----- stdout -----
@@ -976,7 +976,7 @@ fn complex_config_setting_overridden_via_cli() -> Result<()> {
.args(["--config", "lint.per-file-ignores = {'generated.py' = ['N801']}"])
.args(["--stdin-filename", "generated.py"])
.arg("-")
.pass_stdin(test_code), @r"
.pass_stdin(test_code), @"
success: true
exit_code: 0
----- stdout -----
@@ -993,7 +993,7 @@ fn deprecated_config_option_overridden_via_cli() {
.args(STDIN_BASE_OPTIONS)
.args(["--config", "select=['N801']", "-"])
.pass_stdin("class lowercase: ..."),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1061,7 +1061,7 @@ include = ["*.ipy"]
.check_command()
.args(["--config", "ruff.toml"])
.args(["--extension", "ipy:ipynb"])
.arg("."), @r"
.arg("."), @"
success: false
exit_code: 1
----- stdout -----
@@ -1111,7 +1111,7 @@ external = ["AAA"]
.pass_stdin(r#"
# flake8: noqa: AAA101, BBB102
import os
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1147,7 +1147,7 @@ required-version = "0.1.0"
.arg("-")
.pass_stdin(r#"
import os
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -1184,7 +1184,7 @@ required-version = "{version}"
.arg("-")
.pass_stdin(r#"
import os
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1222,7 +1222,7 @@ required-version = ">{version}"
.arg("-")
.pass_stdin(r#"
import os
"#), @r"
"#), @"
success: false
exit_code: 2
----- stdout -----
@@ -1252,7 +1252,7 @@ required-version = ">=0.1.0"
.arg("-")
.pass_stdin(r#"
import os
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1289,7 +1289,7 @@ import os
def func():
x = 1
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1323,7 +1323,7 @@ fn negated_per_file_ignores() -> Result<()> {
.arg("ruff.toml")
.arg("--select")
.arg("RUF901")
, @r"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -1355,7 +1355,7 @@ fn negated_per_file_ignores_absolute() -> Result<()> {
.arg("ruff.toml")
.arg("--select")
.arg("RUF901")
, @r"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -1389,7 +1389,7 @@ fn negated_per_file_ignores_overlap() -> Result<()> {
.arg("ruff.toml")
.arg("--select")
.arg("RUF901")
, @r"
, @"
success: true
exit_code: 0
----- stdout -----
@@ -1423,7 +1423,7 @@ import os # F401
def function():
import os # F811
print(os.name)
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1466,7 +1466,7 @@ import sys
.check_command()
.args(["--config", "ruff.toml"])
.arg("noqa.py"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1482,7 +1482,7 @@ import sys
.args(["--config", "ruff.toml"])
.arg("noqa.py")
.args(["--preview"]),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -1497,7 +1497,7 @@ import sys
.args(["--config", "ruff.toml"])
.arg("noqa.py")
.args(["--ignore-noqa", "--preview"]),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1539,7 +1539,7 @@ def first_square():
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1551,7 +1551,8 @@ def first_square():
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
def first_square():
return [x * x for x in range(20)][0] # noqa: RUF015
");
@@ -1587,7 +1588,7 @@ def unused(x):
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1599,7 +1600,8 @@ def unused(x):
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
def unused(x): # noqa: ANN001, ANN201, D103
pass
");
@@ -1635,7 +1637,7 @@ import a
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1647,7 +1649,8 @@ import a
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
import z # noqa: I001
import c
import a
@@ -1684,7 +1687,7 @@ def unused(x): # noqa: ANN001, ARG001, D103
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1696,7 +1699,8 @@ def unused(x): # noqa: ANN001, ARG001, D103
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
def unused(x): # noqa: ANN001, ANN201, ARG001, D103
pass
");
@@ -1732,7 +1736,7 @@ import os
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1743,7 +1747,8 @@ import os
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
# ruff: noqa F401
import os
");
@@ -1779,7 +1784,7 @@ import os
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1790,7 +1795,8 @@ import os
let test_code =
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r"
insta::assert_snapshot!(test_code, @"
# ruff: disable[F401]
import os
");
@@ -1831,7 +1837,7 @@ print(
.arg("-")
.pass_stdin(r#"
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -1844,6 +1850,7 @@ print(
fs::read_to_string(fixture.root().join("noqa.py")).expect("should read test file");
insta::assert_snapshot!(test_code, @r#"
print(
"""First line
second line
@@ -1886,7 +1893,7 @@ def first_square():
assert_cmd_snapshot!(fixture
.check_command()
.args(["--add-noqa"]), @r"
.args(["--add-noqa"]), @"
success: true
exit_code: 0
----- stdout -----
@@ -1915,7 +1922,7 @@ from foo import ( # noqa: F401
.check_command()
.arg("--add-noqa")
.arg("--select=F401")
.arg("noqa.py"), @r"
.arg("noqa.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -1942,7 +1949,7 @@ def foo():
.check_command()
.arg("--add-noqa=TODO: fix")
.arg("--select=F401,F841")
.arg("test.py"), @r"
.arg("test.py"), @"
success: true
exit_code: 0
----- stdout -----
@@ -1952,12 +1959,12 @@ def foo():
");
let content = fs::read_to_string(fixture.root().join("test.py"))?;
insta::assert_snapshot!(content, @r"
import os # noqa: F401 TODO: fix
insta::assert_snapshot!(content, @"
import os # noqa: F401 TODO: fix
def foo():
x = 1 # noqa: F841 TODO: fix
");
def foo():
x = 1 # noqa: F841 TODO: fix
");
Ok(())
}
@@ -1971,7 +1978,7 @@ fn add_noqa_with_newline_in_reason() -> Result<()> {
.check_command()
.arg("--add-noqa=line1\nline2")
.arg("--select=F401")
.arg("test.py"), @r###"
.arg("test.py"), @"
success: false
exit_code: 2
----- stdout -----
@@ -1979,7 +1986,7 @@ fn add_noqa_with_newline_in_reason() -> Result<()> {
----- stderr -----
ruff failed
Cause: --add-noqa <reason> cannot contain newline characters
"###);
");
Ok(())
}
@@ -2003,7 +2010,7 @@ select = ["UP006"]
.arg("pyproject.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"from typing import List; foo: List[int]"#), @r"
.pass_stdin(r#"from typing import List; foo: List[int]"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -2030,7 +2037,7 @@ select = ["UP006"]
.arg("pyproject.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"from typing import List; foo: List[int]"#), @r"
.pass_stdin(r#"from typing import List; foo: List[int]"#), @"
success: true
exit_code: 0
----- stdout -----
@@ -2061,7 +2068,7 @@ select = ["UP006"]
.arg("pyproject.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"from typing import List; foo: List[int]"#), @r"
.pass_stdin(r#"from typing import List; foo: List[int]"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -2094,7 +2101,7 @@ select = ["UP006"]
.arg("pyproject.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"from typing import List; foo: List[int]"#), @r"
.pass_stdin(r#"from typing import List; foo: List[int]"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -2127,7 +2134,7 @@ select = ["UP006"]
.arg("pyproject.toml")
.args(["--stdin-filename", "test.py"])
.arg("-")
.pass_stdin(r#"from typing import List; foo: List[int]"#), @r"
.pass_stdin(r#"from typing import List; foo: List[int]"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -2263,7 +2270,7 @@ requires-python = ">= 3.11"
.check_command()
.args(["--select","UP007"])
.arg(".")
, @r###"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -2272,7 +2279,7 @@ requires-python = ">= 3.11"
[*] 1 fixable with the `--fix` option.
----- stderr -----
"###);
");
Ok(())
}
@@ -2348,7 +2355,7 @@ from typing import Union;foo: Union[int, str] = 1"#,
assert_cmd_snapshot!(fixture
.check_command()
.arg("test.py")
, @r"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -2591,7 +2598,7 @@ fn checks_notebooks_in_stable() -> anyhow::Result<()> {
.check_command()
.arg("--select")
.arg("F401")
, @r"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -2619,7 +2626,7 @@ fn nested_implicit_namespace_package() -> Result<()> {
.check_command()
.arg("--select")
.arg("INP")
, @r"
, @"
success: true
exit_code: 0
----- stdout -----
@@ -2633,7 +2640,7 @@ fn nested_implicit_namespace_package() -> Result<()> {
.arg("--select")
.arg("INP")
.arg("--preview")
, @r"
, @"
success: false
exit_code: 1
----- stdout -----
@@ -2764,7 +2771,7 @@ fn flake8_import_convention_nfkc_normalization() -> Result<()> {
.arg("ruff.toml")
.arg("-")
.pass_stdin("")
, @r###"
, @"
success: false
exit_code: 2
----- stdout -----
@@ -2772,7 +2779,7 @@ fn flake8_import_convention_nfkc_normalization() -> Result<()> {
----- stderr -----
ruff failed
Cause: Invalid alias for module 'test.module': alias normalizes to '__debug__', which is not allowed.
"###);
");
Ok(())
}
@@ -2822,7 +2829,7 @@ fn pyupgrade_up026_respects_isort_required_import_fix() {
.arg("--fix")
.arg("--no-cache")
.pass_stdin("1\n"),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2849,7 +2856,7 @@ fn pyupgrade_up026_respects_isort_required_import_from_fix() {
.arg("--fix")
.arg("--no-cache")
.pass_stdin("from mock import mock\n"),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2883,7 +2890,7 @@ d: Literal[None,] | Literal[None]
.arg("--preview")
.arg("--diff")
.arg("-")
.pass_stdin(snippet), @r"
.pass_stdin(snippet), @"
success: false
exit_code: 1
----- stdout -----
@@ -2937,7 +2944,7 @@ def func(t: _T) -> _T:
return x
"#
),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2976,7 +2983,7 @@ class Foo[_T, __T]:
pass
"#
),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3041,7 +3048,7 @@ fn a005_module_shadowing_strict() -> Result<()> {
.arg("--config")
.arg(r#"lint.flake8-builtins.strict-checking = true"#)
.args(["--select", "A005"]),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3069,7 +3076,7 @@ fn a005_module_shadowing_non_strict() -> Result<()> {
.arg("--config")
.arg(r#"lint.flake8-builtins.strict-checking = false"#)
.args(["--select", "A005"]),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3094,7 +3101,7 @@ fn a005_module_shadowing_strict_default() -> Result<()> {
assert_cmd_snapshot!(fixture.check_command()
.args(["--select", "A005"]),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3127,7 +3134,7 @@ T = TypeVar("T")
class A(Generic[T]):
var: T
"#),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3157,7 +3164,7 @@ T = TypeVar("T")
class A(Generic[T]):
var: T
"#),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -3177,7 +3184,7 @@ fn walrus_before_py38() {
.arg("--target-version=py38")
.arg("-")
.pass_stdin(r#"(x := 1)"#),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -3195,7 +3202,7 @@ fn walrus_before_py38() {
.arg("--preview")
.arg("-")
.pass_stdin(r#"(x := 1)"#),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3222,7 +3229,7 @@ match 2:
print("it's one")
"#
),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -3245,7 +3252,7 @@ match 2:
print("it's one")
"#
),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3270,7 +3277,7 @@ match 2:
print("it's one")
"#
),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3296,7 +3303,7 @@ fn cache_syntax_errors() -> Result<()> {
assert_cmd_snapshot!(
cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3309,7 +3316,7 @@ fn cache_syntax_errors() -> Result<()> {
// this should *not* be cached, like normal parse errors
assert_cmd_snapshot!(
cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3345,14 +3352,14 @@ fn cookiecutter_globbing() -> Result<()> {
assert_cmd_snapshot!(fixture
.check_command()
.arg("--select=F811"), @r"
success: true
exit_code: 0
----- stdout -----
All checks passed!
.arg("--select=F811"), @"
success: true
exit_code: 0
----- stdout -----
All checks passed!
----- stderr -----
");
----- stderr -----
");
// after removing the config file with the ignore, F811 applies, so the glob worked above
fs::remove_file(
@@ -3363,7 +3370,7 @@ fn cookiecutter_globbing() -> Result<()> {
assert_cmd_snapshot!(fixture
.check_command()
.arg("--select=F811"), @r"
.arg("--select=F811"), @"
success: false
exit_code: 1
----- stdout -----
@@ -3388,15 +3395,15 @@ fn cookiecutter_globbing_no_project_root() -> Result<()> {
assert_cmd_snapshot!(fixture
.check_command()
.current_dir(fixture.root().join("{{cookiecutter.repo_name}}"))
.args(["--extend-per-file-ignores", "generated.py:Q"]), @r"
success: true
exit_code: 0
----- stdout -----
All checks passed!
.args(["--extend-per-file-ignores", "generated.py:Q"]), @"
success: true
exit_code: 0
----- stdout -----
All checks passed!
----- stderr -----
warning: No Python files found under the given path(s)
");
----- stderr -----
warning: No Python files found under the given path(s)
");
Ok(())
}
@@ -3417,7 +3424,7 @@ fn semantic_syntax_errors() -> Result<()> {
assert_cmd_snapshot!(
cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3431,7 +3438,7 @@ fn semantic_syntax_errors() -> Result<()> {
// this should *not* be cached, like normal parse errors
assert_cmd_snapshot!(
cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3449,7 +3456,7 @@ fn semantic_syntax_errors() -> Result<()> {
.arg("--preview")
.arg("-")
.pass_stdin(contents),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3483,7 +3490,7 @@ class Foo:
.arg("--target-version=py39")
.arg("-")
.pass_stdin(contents),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -3581,7 +3588,7 @@ nested_optional: Optional[Optional[Optional[str]]] = None
.args(["--select", "UP045", "--diff", "--target-version", "py312"])
.arg("-")
.pass_stdin(contents),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3606,7 +3613,7 @@ fn show_fixes_in_full_output_with_preview_enabled() {
.arg("--preview")
.arg("-")
.pass_stdin("import math"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3637,7 +3644,7 @@ fn rule_panic_mixed_results_concise() -> Result<()> {
fixture.check_command()
.args(["--select", "RUF9", "--preview"])
.args(["normal.py", "panic.py"]),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -3672,7 +3679,7 @@ fn rule_panic_mixed_results_full() -> Result<()> {
fixture.command()
.args(["check", "--select", "RUF9", "--preview", "--output-format=full", "--no-cache"])
.args(["normal.py", "panic.py"]),
@r"
@"
success: false
exit_code: 2
----- stdout -----
@@ -3781,7 +3788,7 @@ fn supported_file_extensions() -> Result<()> {
fixture.check_command()
.args(["--select", "F401"])
.arg("src"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -3861,7 +3868,7 @@ fn supported_file_extensions_preview_enabled() -> Result<()> {
fixture.check_command()
.args(["--select", "F401", "--preview"])
.arg("src"),
@r"
@"
success: false
exit_code: 1
----- stdout -----

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:
@@ -17,7 +17,6 @@ info:
- "--fix"
- "-"
stdin: "1"
snapshot_kind: text
---
success: false
exit_code: 2

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -12,7 +12,6 @@ info:
- "--target-version"
- py39
- input.py
snapshot_kind: text
---
success: false
exit_code: 1

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -1,5 +1,5 @@
---
source: crates/ruff/tests/lint.rs
source: crates/ruff/tests/cli/lint.rs
info:
program: ruff
args:

View File

@@ -18,13 +18,13 @@ fn check_in_deleted_directory_errors() {
set_current_dir(&temp_path).unwrap();
drop(temp_dir);
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)).arg("check"), @r###"
success: false
exit_code: 2
----- stdout -----
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)).arg("check"), @"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
ruff failed
Cause: Working directory does not exist
"###);
----- stderr -----
ruff failed
Cause: Working directory does not exist
");
}

View File

@@ -97,7 +97,7 @@ impl<'a> RuffCheck<'a> {
fn stdin_success() {
let mut cmd = RuffCheck::default().args([]).build();
assert_cmd_snapshot!(cmd
.pass_stdin(""), @r"
.pass_stdin(""), @"
success: true
exit_code: 0
----- stdout -----
@@ -111,7 +111,7 @@ fn stdin_success() {
fn stdin_error() {
let mut cmd = RuffCheck::default().args([]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -136,7 +136,7 @@ fn stdin_filename() {
.args(["--stdin-filename", "F401.py"])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -172,7 +172,7 @@ import bar # unused import
)?;
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--isolated", "--no-cache", "--select", "F401"]).current_dir(tempdir.path()), @r"
.args(["check", "--isolated", "--no-cache", "--select", "F401"]).current_dir(tempdir.path()), @"
success: false
exit_code: 1
----- stdout -----
@@ -208,7 +208,7 @@ fn check_warn_stdin_filename_with_files() {
.filename("foo.py")
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -235,7 +235,7 @@ fn stdin_source_type_py() {
.args(["--stdin-filename", "TCH.py"])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -261,7 +261,7 @@ fn stdin_source_type_pyi() {
.args(["--stdin-filename", "TCH.pyi", "--select", "TCH"])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: true
exit_code: 0
----- stdout -----
@@ -294,7 +294,7 @@ fn stdin_json() {
fn stdin_fix_py() {
let mut cmd = RuffCheck::default().args(["--fix"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\nimport sys\n\nprint(sys.version)\n"), @r"
.pass_stdin("import os\nimport sys\n\nprint(sys.version)\n"), @"
success: true
exit_code: 0
----- stdout -----
@@ -572,7 +572,7 @@ fn stdin_override_parser_ipynb() {
},
"nbformat": 4,
"nbformat_minor": 5
}"#), @r"
}"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -610,7 +610,7 @@ fn stdin_override_parser_py() {
])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\n"), @r"
.pass_stdin("import os\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -633,7 +633,7 @@ fn stdin_override_parser_py() {
fn stdin_fix_when_not_fixable_should_still_print_contents() {
let mut cmd = RuffCheck::default().args(["--fix"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n"), @r###"
.pass_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -654,14 +654,14 @@ fn stdin_fix_when_not_fixable_should_still_print_contents() {
|
Found 2 errors (1 fixed, 1 remaining).
"###);
");
}
#[test]
fn stdin_fix_when_no_issues_should_still_print_contents() {
let mut cmd = RuffCheck::default().args(["--fix"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("import sys\n\nprint(sys.version)\n"), @r"
.pass_stdin("import sys\n\nprint(sys.version)\n"), @"
success: true
exit_code: 0
----- stdout -----
@@ -805,7 +805,7 @@ fn stdin_format_jupyter() {
fn stdin_parse_error() {
let mut cmd = RuffCheck::default().build();
assert_cmd_snapshot!(cmd
.pass_stdin("from foo import\n"), @r"
.pass_stdin("from foo import\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -826,7 +826,7 @@ fn stdin_parse_error() {
fn stdin_multiple_parse_error() {
let mut cmd = RuffCheck::default().build();
assert_cmd_snapshot!(cmd
.pass_stdin("from foo import\nbar =\n"), @r"
.pass_stdin("from foo import\nbar =\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -857,7 +857,7 @@ fn parse_error_not_included() {
// Parse errors are always shown
let mut cmd = RuffCheck::default().args(["--select=I"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("foo =\n"), @r"
.pass_stdin("foo =\n"), @"
success: false
exit_code: 1
----- stdout -----
@@ -878,7 +878,7 @@ fn parse_error_not_included() {
fn full_output_preview() {
let mut cmd = RuffCheck::default().args(["--preview"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("l = 1"), @r"
.pass_stdin("l = 1"), @"
success: false
exit_code: 1
----- stdout -----
@@ -907,7 +907,7 @@ preview = true
",
)?;
let mut cmd = RuffCheck::default().config(&pyproject_toml).build();
assert_cmd_snapshot!(cmd.pass_stdin("l = 1"), @r"
assert_cmd_snapshot!(cmd.pass_stdin("l = 1"), @"
success: false
exit_code: 1
----- stdout -----
@@ -929,7 +929,7 @@ preview = true
fn full_output_format() {
let mut cmd = RuffCheck::default().output_format("full").build();
assert_cmd_snapshot!(cmd
.pass_stdin("l = 1"), @r"
.pass_stdin("l = 1"), @"
success: false
exit_code: 1
----- stdout -----
@@ -967,7 +967,7 @@ fn rule_f401_output_text() {
#[test]
fn rule_invalid_rule_name() {
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404"]), @r"
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404"]), @"
success: false
exit_code: 2
----- stdout -----
@@ -981,7 +981,7 @@ fn rule_invalid_rule_name() {
#[test]
fn rule_invalid_rule_name_output_json() {
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404", "--output-format", "json"]), @r"
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404", "--output-format", "json"]), @"
success: false
exit_code: 2
----- stdout -----
@@ -995,7 +995,7 @@ fn rule_invalid_rule_name_output_json() {
#[test]
fn rule_invalid_rule_name_output_text() {
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404", "--output-format", "text"]), @r"
assert_cmd_snapshot!(ruff_cmd().args(["rule", "RUF404", "--output-format", "text"]), @"
success: false
exit_code: 2
----- stdout -----
@@ -1016,7 +1016,7 @@ fn show_statistics() {
.pass_stdin(r#"
def mvce(keys, values):
return {key: value for key, value in zip(keys, values)}
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1037,7 +1037,7 @@ fn show_statistics_unsafe_fixes() {
.pass_stdin(r#"
def mvce(keys, values):
return {key: value for key, value in zip(keys, values)}
"#), @r"
"#), @"
success: false
exit_code: 1
----- stdout -----
@@ -1152,7 +1152,7 @@ fn show_statistics_partial_fix() {
.args(["--select", "UP035", "--statistics"])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("from typing import List, AsyncGenerator"), @r"
.pass_stdin("from typing import List, AsyncGenerator"), @"
success: false
exit_code: 1
----- stdout -----
@@ -1173,7 +1173,7 @@ fn show_statistics_syntax_errors() {
// ParseError
assert_cmd_snapshot!(
cmd.pass_stdin("x ="),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1186,7 +1186,7 @@ fn show_statistics_syntax_errors() {
// match before 3.10, UnsupportedSyntaxError
assert_cmd_snapshot!(
cmd.pass_stdin("match 2:\n case 1: ..."),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1199,7 +1199,7 @@ fn show_statistics_syntax_errors() {
// rebound comprehension variable, SemanticSyntaxError
assert_cmd_snapshot!(
cmd.pass_stdin("[x := 1 for x in range(0)]"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1216,7 +1216,7 @@ fn preview_enabled_prefix() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF9", "--output-format=concise", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1238,7 +1238,7 @@ fn preview_enabled_all() {
let mut cmd = RuffCheck::default()
.args(["--select", "ALL", "--output-format=concise", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1265,7 +1265,7 @@ fn preview_enabled_direct() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF911", "--output-format=concise", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1282,7 +1282,7 @@ fn preview_disabled_direct() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF911", "--output-format=concise"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1299,7 +1299,7 @@ fn preview_disabled_prefix_empty() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF91", "--output-format=concise"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1316,7 +1316,7 @@ fn preview_disabled_does_not_warn_for_empty_ignore_selections() {
let mut cmd = RuffCheck::default()
.args(["--ignore", "RUF9", "--output-format=concise"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1332,7 +1332,7 @@ fn preview_disabled_does_not_warn_for_empty_fixable_selections() {
let mut cmd = RuffCheck::default()
.args(["--fixable", "RUF9", "--output-format=concise"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1354,7 +1354,7 @@ fn preview_group_selector() {
])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("I=42\n"), @r"
.pass_stdin("I=42\n"), @"
success: false
exit_code: 2
----- stdout -----
@@ -1379,7 +1379,7 @@ fn preview_enabled_group_ignore() {
"--output-format=concise",
])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1400,7 +1400,7 @@ fn preview_enabled_group_ignore() {
fn removed_direct() {
// Selection of a removed rule should fail
let mut cmd = RuffCheck::default().args(["--select", "RUF931"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
@@ -1418,7 +1418,7 @@ fn removed_direct_multiple() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF930", "--select", "RUF931"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
@@ -1436,7 +1436,7 @@ fn removed_indirect() {
// Selection _including_ a removed rule without matching should not fail
// nor should the rule be used
let mut cmd = RuffCheck::default().args(["--select", "RUF93"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1449,7 +1449,7 @@ fn removed_indirect() {
#[test]
fn removed_ignore_direct() {
let mut cmd = RuffCheck::default().args(["--ignore", "UP027"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1466,7 +1466,7 @@ fn removed_ignore_multiple_direct() {
let mut cmd = RuffCheck::default()
.args(["--ignore", "UP027", "--ignore", "PLR1706"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1482,7 +1482,7 @@ fn removed_ignore_multiple_direct() {
#[test]
fn removed_ignore_remapped_direct() {
let mut cmd = RuffCheck::default().args(["--ignore", "PGH001"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1498,7 +1498,7 @@ fn removed_ignore_indirect() {
// `PLR170` includes removed rules but should not select or warn
// since it is not a "direct" selection
let mut cmd = RuffCheck::default().args(["--ignore", "PLR170"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1512,7 +1512,7 @@ fn removed_ignore_indirect() {
fn redirect_direct() {
// Selection of a redirected rule directly should use the new rule and warn
let mut cmd = RuffCheck::default().args(["--select", "RUF940"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1531,7 +1531,7 @@ fn redirect_indirect() {
// Selection _including_ a redirected rule without matching should not fail
// nor should the rule be used
let mut cmd = RuffCheck::default().args(["--select", "RUF94"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1546,7 +1546,7 @@ fn redirect_prefix() {
// Selection using a redirected prefix should switch to all rules in the
// new prefix
let mut cmd = RuffCheck::default().args(["--select", "RUF96"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1565,7 +1565,7 @@ fn deprecated_direct() {
// Selection of a deprecated rule without preview enabled should still work
// but a warning should be displayed
let mut cmd = RuffCheck::default().args(["--select", "RUF920"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1586,7 +1586,7 @@ fn deprecated_multiple_direct() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF920", "--select", "RUF921"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 1
----- stdout -----
@@ -1609,7 +1609,7 @@ fn deprecated_indirect() {
// `RUF92` includes deprecated rules but should not warn
// since it is not a "direct" selection
let mut cmd = RuffCheck::default().args(["--select", "RUF92"]).build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1625,7 +1625,7 @@ fn deprecated_direct_preview_enabled() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF920", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
@@ -1642,7 +1642,7 @@ fn deprecated_indirect_preview_enabled() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF92", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1659,7 +1659,7 @@ fn deprecated_multiple_direct_preview_enabled() {
let mut cmd = RuffCheck::default()
.args(["--select", "RUF920", "--select", "RUF921", "--preview"])
.build();
assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
@@ -1720,7 +1720,7 @@ fn unreadable_dir() -> Result<()> {
.filename(unreadable_dir.to_str().unwrap())
.args([])
.build();
assert_cmd_snapshot!(cmd, @r###"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
@@ -1728,7 +1728,7 @@ fn unreadable_dir() -> Result<()> {
----- stderr -----
warning: Encountered error: Permission denied (os error 13)
"###);
");
Ok(())
}
@@ -1758,7 +1758,7 @@ fn check_input_from_argfile() -> Result<()> {
(file_a_path.display().to_string().as_str(), "/path/to/a.py"),
]}, {
assert_cmd_snapshot!(cmd
.pass_stdin(""), @r"
.pass_stdin(""), @"
success: false
exit_code: 1
----- stdout -----
@@ -1787,17 +1787,17 @@ fn missing_argfile_reports_error() {
insta::with_settings!({filters => vec![
("The system cannot find the file specified.", "No such file or directory")
]}, {
assert_cmd_snapshot!(cmd, @r"
success: false
exit_code: 2
----- stdout -----
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
ruff failed
Cause: Failed to read CLI arguments from files
Cause: failed to open file `!.txt`
Cause: No such file or directory (os error 2)
");
----- stderr -----
ruff failed
Cause: Failed to read CLI arguments from files
Cause: failed to open file `!.txt`
Cause: No such file or directory (os error 2)
");
});
}
@@ -1807,7 +1807,7 @@ fn check_hints_hidden_unsafe_fixes() {
.args(["--select", "RUF901,RUF902"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1829,7 +1829,7 @@ fn check_hints_hidden_unsafe_fixes_with_no_safe_fixes() {
let mut cmd = RuffCheck::default().args(["--select", "RUF902"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("x = {'a': 1, 'a': 1}\n"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1849,7 +1849,7 @@ fn check_no_hint_for_hidden_unsafe_fixes_when_disabled() {
.args(["--select", "RUF901,RUF902", "--no-unsafe-fixes"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1873,7 +1873,7 @@ fn check_no_hint_for_hidden_unsafe_fixes_with_no_safe_fixes_when_disabled() {
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("x = {'a': 1, 'a': 1}\n"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1892,7 +1892,7 @@ fn check_shows_unsafe_fixes_with_opt_in() {
.args(["--select", "RUF901,RUF902", "--unsafe-fixes"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1915,7 +1915,7 @@ fn fix_applies_safe_fixes_by_default() {
.args(["--select", "RUF901,RUF902", "--fix"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1936,7 +1936,7 @@ fn fix_applies_unsafe_fixes_with_opt_in() {
.args(["--select", "RUF901,RUF902", "--fix", "--unsafe-fixes"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -1955,7 +1955,7 @@ fn fix_does_not_apply_display_only_fixes() {
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("def add_to_list(item, some_list=[]): ..."),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1975,7 +1975,7 @@ fn fix_does_not_apply_display_only_fixes_with_unsafe_fixes_enabled() {
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("def add_to_list(item, some_list=[]): ..."),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -1994,7 +1994,7 @@ fn fix_only_unsafe_fixes_available() {
.args(["--select", "RUF902", "--fix"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2014,7 +2014,7 @@ fn fix_only_flag_applies_safe_fixes_by_default() {
.args(["--select", "RUF901,RUF902", "--fix-only"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2031,7 +2031,7 @@ fn fix_only_flag_applies_unsafe_fixes_with_opt_in() {
.args(["--select", "RUF901,RUF902", "--fix-only", "--unsafe-fixes"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2049,7 +2049,7 @@ fn diff_shows_safe_fixes_by_default() {
.args(["--select", "RUF901,RUF902", "--diff"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2069,7 +2069,7 @@ fn diff_shows_unsafe_fixes_with_opt_in() {
.args(["--select", "RUF901,RUF902", "--diff", "--unsafe-fixes"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2091,7 +2091,7 @@ fn diff_does_not_show_display_only_fixes_with_unsafe_fixes_enabled() {
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("def add_to_list(item, some_list=[]): ..."),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2106,7 +2106,7 @@ fn diff_only_unsafe_fixes_available() {
.args(["--select", "RUF902", "--diff"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2134,7 +2134,7 @@ extend-unsafe-fixes = ["RUF901"]
.args(["--select", "RUF901,RUF902"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2170,7 +2170,7 @@ extend-safe-fixes = ["RUF902"]
.args(["--select", "RUF901,RUF902"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2208,7 +2208,7 @@ extend-safe-fixes = ["RUF902"]
.args(["--select", "RUF901,RUF902"])
.build();
assert_cmd_snapshot!(cmd,
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2248,7 +2248,7 @@ extend-safe-fixes = ["RUF9"]
.build();
assert_cmd_snapshot!(cmd
.pass_stdin("x = {'a': 1, 'a': 1}\nprint(('foo'))\nprint(str('foo'))\nisinstance(x, (int, str))\n"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2307,7 +2307,7 @@ def log(x, base) -> float:
.args(["--select", "D41"])
.build();
assert_cmd_snapshot!(cmd
.pass_stdin(stdin), @r"
.pass_stdin(stdin), @"
success: true
exit_code: 0
----- stdout -----
@@ -2360,7 +2360,7 @@ select = ["RUF017"]
let mut cmd = RuffCheck::default().config(&ruff_toml).build();
assert_cmd_snapshot!(cmd
.pass_stdin("x = [1, 2, 3]\ny = [4, 5, 6]\nsum([x, y], [])"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2401,7 +2401,7 @@ unfixable = ["RUF"]
let mut cmd = RuffCheck::default().config(&ruff_toml).build();
assert_cmd_snapshot!(cmd
.pass_stdin("x = [1, 2, 3]\ny = [4, 5, 6]\nsum([x, y], [])"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2431,7 +2431,7 @@ fn pyproject_toml_stdin_syntax_error() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2457,7 +2457,7 @@ fn pyproject_toml_stdin_schema_error() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project]\nname = 1"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2484,7 +2484,7 @@ fn pyproject_toml_stdin_no_applicable_rules_selected() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project"),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2503,7 +2503,7 @@ fn pyproject_toml_stdin_no_applicable_rules_selected_2() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project"),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2522,7 +2522,7 @@ fn pyproject_toml_stdin_no_errors() {
assert_cmd_snapshot!(
cmd.pass_stdin(r#"[project]\nname = "ruff"\nversion = "0.0.0""#),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2547,7 +2547,7 @@ fn pyproject_toml_stdin_schema_error_fix() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project]\nname = 1"),
@r"
@"
success: false
exit_code: 1
----- stdout -----
@@ -2581,7 +2581,7 @@ fn pyproject_toml_stdin_schema_error_fix_only() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project]\nname = 1"),
@r"
@"
success: true
exit_code: 0
----- stdout -----
@@ -2607,7 +2607,7 @@ fn pyproject_toml_stdin_schema_error_fix_diff() {
assert_cmd_snapshot!(
cmd.pass_stdin("[project]\nname = 1"),
@r"
@"
success: true
exit_code: 0
----- stdout -----

View File

@@ -29,7 +29,7 @@ fn check_project_include_defaults() {
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r"
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @"
success: true
exit_code: 0
----- stdout -----
@@ -53,7 +53,7 @@ fn check_project_respects_direct_paths() {
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files", "b.py"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r"
.args(["check", "--show-files", "b.py"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @"
success: true
exit_code: 0
----- stdout -----
@@ -72,7 +72,7 @@ fn check_project_respects_subdirectory_includes() {
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files", "subdirectory"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r"
.args(["check", "--show-files", "subdirectory"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @"
success: true
exit_code: 0
----- stdout -----
@@ -91,7 +91,7 @@ fn check_project_from_project_subdirectory_respects_includes() {
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test/subdirectory")), @r"
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test/subdirectory")), @"
success: true
exit_code: 0
----- stdout -----

View File

@@ -3,11 +3,12 @@ source: crates/ruff/tests/integration_test.rs
info:
program: ruff
args:
- "-"
- "--isolated"
- "--no-cache"
- check
- "--output-format"
- json
- "--no-cache"
- "--isolated"
- "-"
- "--stdin-filename"
- F401.py
stdin: "import os\n"
@@ -51,4 +52,3 @@ exit_code: 1
}
]
----- stderr -----

View File

@@ -16,7 +16,7 @@ const VERSION_FILTER: [(&str, &str); 1] = [(
fn version_basics() {
insta::with_settings!({filters => VERSION_FILTER.to_vec()}, {
assert_cmd_snapshot!(
Command::new(get_cargo_bin(BIN_NAME)).arg("version"), @r"
Command::new(get_cargo_bin(BIN_NAME)).arg("version"), @"
success: true
exit_code: 0
----- stdout -----
@@ -42,7 +42,7 @@ fn config_option_allowed_but_ignored() -> Result<()> {
.arg("version")
.arg("--config")
.arg(&ruff_dot_toml)
.args(["--config", "lint.isort.extra-standard-library = ['foo', 'bar']"]), @r"
.args(["--config", "lint.isort.extra-standard-library = ['foo', 'bar']"]), @"
success: true
exit_code: 0
----- stdout -----
@@ -60,7 +60,7 @@ fn config_option_ignored_but_validated() {
assert_cmd_snapshot!(
Command::new(get_cargo_bin(BIN_NAME))
.arg("version")
.args(["--config", "foo = bar"]), @r"
.args(["--config", "foo = bar"]), @"
success: false
exit_code: 2
----- stdout -----
@@ -91,7 +91,7 @@ fn config_option_ignored_but_validated() {
fn isolated_option_allowed() {
insta::with_settings!({filters => VERSION_FILTER.to_vec()}, {
assert_cmd_snapshot!(
Command::new(get_cargo_bin(BIN_NAME)).arg("version").arg("--isolated"), @r"
Command::new(get_cargo_bin(BIN_NAME)).arg("version").arg("--isolated"), @"
success: true
exit_code: 0
----- stdout -----

View File

@@ -1284,7 +1284,7 @@ watermelon
let diag = env.err().primary("animals", "5", "5", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1308,7 +1308,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
warning[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1328,7 +1328,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
info[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1355,7 +1355,7 @@ watermelon
let diag = builder.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1374,7 +1374,7 @@ watermelon
let diag = builder.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1395,7 +1395,7 @@ watermelon
let diag = env.err().primary("non-ascii", "5", "5", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> non-ascii:5:1
|
@@ -1414,7 +1414,7 @@ watermelon
let diag = env.err().primary("non-ascii", "2:4", "2:8", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> non-ascii:2:2
|
@@ -1438,7 +1438,7 @@ watermelon
env.context(1);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1455,7 +1455,7 @@ watermelon
env.context(0);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1470,7 +1470,7 @@ watermelon
env.context(2);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1487,7 +1487,7 @@ watermelon
env.context(2);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:11:1
|
@@ -1504,7 +1504,7 @@ watermelon
env.context(200);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -1537,7 +1537,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1581,7 +1581,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1606,7 +1606,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1634,7 +1634,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1662,7 +1662,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1687,7 +1687,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1718,7 +1718,7 @@ watermelon
// window.
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:1:1
|
@@ -1756,7 +1756,7 @@ watermelon
let diag = env.err().primary("spacey-animals", "8", "8", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> spacey-animals:8:1
|
@@ -1773,7 +1773,7 @@ watermelon
let diag = env.err().primary("spacey-animals", "12", "12", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> spacey-animals:12:1
|
@@ -1791,7 +1791,7 @@ watermelon
let diag = env.err().primary("spacey-animals", "13", "13", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> spacey-animals:13:1
|
@@ -1831,7 +1831,7 @@ watermelon
// instead of special casing the snippet assembly.
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> spacey-animals:3:1
|
@@ -1860,7 +1860,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -1897,7 +1897,7 @@ watermelon
);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -1934,7 +1934,7 @@ watermelon
);
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -1962,7 +1962,7 @@ watermelon
diag.sub(env.sub_warn().primary("fruits", "3", "3", "").build());
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -1998,7 +1998,7 @@ watermelon
diag.sub(env.sub_warn().primary("animals", "11", "11", "").build());
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -2037,7 +2037,7 @@ watermelon
diag.sub(env.sub_warn().primary("fruits", "3", "3", "").build());
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -2085,7 +2085,7 @@ watermelon
diag.sub(env.sub_warn().secondary("animals", "3", "3", "").build());
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:3:1
|
@@ -2121,7 +2121,7 @@ watermelon
let diag = env.err().primary("animals", "5", "6", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2144,7 +2144,7 @@ watermelon
let diag = env.err().primary("animals", "5", "7:0", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2164,7 +2164,7 @@ watermelon
let diag = env.err().primary("animals", "5", "7:1", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2184,7 +2184,7 @@ watermelon
let diag = env.err().primary("animals", "5:3", "8:8", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:4
|
@@ -2206,7 +2206,7 @@ watermelon
let diag = env.err().secondary("animals", "5:3", "8:8", "").build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:4
|
@@ -2238,7 +2238,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:4:1
|
@@ -2267,7 +2267,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:4:1
|
@@ -2298,7 +2298,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2333,7 +2333,7 @@ watermelon
// better using only ASCII art.
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2361,7 +2361,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2393,7 +2393,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:3
|
@@ -2415,7 +2415,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:3
|
@@ -2448,7 +2448,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:8:1
|
@@ -2488,7 +2488,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:5:1
|
@@ -2532,7 +2532,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> fruits:1:1
|
@@ -2567,7 +2567,7 @@ watermelon
.build();
insta::assert_snapshot!(
env.render(&diag),
@r"
@"
error[test-diagnostic]: main diagnostic message
--> animals:11:1
|

View File

@@ -137,7 +137,7 @@ mod tests {
#[test]
fn output() {
let (env, diagnostics) = create_diagnostics(DiagnosticFormat::Concise);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
fib.py:1:8: error[unused-import] `os` imported but unused
fib.py:6:5: error[unused-variable] Local variable `x` is assigned to but never used
undef.py:1:4: error[undefined-name] Undefined name `a`
@@ -150,7 +150,7 @@ mod tests {
env.hide_severity(true);
env.show_fix_status(true);
env.fix_applicability(Applicability::DisplayOnly);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
fib.py:1:8: F401 [*] `os` imported but unused
fib.py:6:5: F841 [*] Local variable `x` is assigned to but never used
undef.py:1:4: F821 Undefined name `a`
@@ -164,7 +164,7 @@ mod tests {
env.show_fix_status(true);
env.fix_applicability(Applicability::DisplayOnly);
env.preview(true);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
fib.py:1:8: F401 [*] `os` imported but unused
fib.py:6:5: F841 [*] Local variable `x` is assigned to but never used
undef.py:1:4: F821 Undefined name `a`
@@ -177,7 +177,7 @@ mod tests {
env.hide_severity(true);
env.show_fix_status(true);
env.fix_applicability(Applicability::DisplayOnly);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
syntax_errors.py:1:15: invalid-syntax: Expected one or more symbol names after import
syntax_errors.py:3:12: invalid-syntax: Expected ')', found newline
");
@@ -186,7 +186,7 @@ mod tests {
#[test]
fn syntax_errors() {
let (env, diagnostics) = create_syntax_error_diagnostics(DiagnosticFormat::Concise);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
syntax_errors.py:1:15: error[invalid-syntax] Expected one or more symbol names after import
syntax_errors.py:3:12: error[invalid-syntax] Expected ')', found newline
");
@@ -195,7 +195,7 @@ mod tests {
#[test]
fn notebook_output() {
let (env, diagnostics) = create_notebook_diagnostics(DiagnosticFormat::Concise);
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r"
insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @"
notebook.ipynb:cell 1:2:8: error[unused-import] `os` imported but unused
notebook.ipynb:cell 2:2:8: error[unused-import] `math` imported but unused
notebook.ipynb:cell 3:4:5: error[unused-variable] Local variable `x` is assigned to but never used

View File

@@ -619,19 +619,19 @@ pub(crate) mod tests {
fn read_directory_stdlib() {
let mock_typeshed = mock_typeshed();
assert_snapshot!(readdir_snapshot(&mock_typeshed, "stdlib"), @r"
assert_snapshot!(readdir_snapshot(&mock_typeshed, "stdlib"), @"
vendored://stdlib/asyncio/
vendored://stdlib/functools.pyi
");
assert_snapshot!(readdir_snapshot(&mock_typeshed, "stdlib/"), @r"
assert_snapshot!(readdir_snapshot(&mock_typeshed, "stdlib/"), @"
vendored://stdlib/asyncio/
vendored://stdlib/functools.pyi
");
assert_snapshot!(readdir_snapshot(&mock_typeshed, "./stdlib"), @r"
assert_snapshot!(readdir_snapshot(&mock_typeshed, "./stdlib"), @"
vendored://stdlib/asyncio/
vendored://stdlib/functools.pyi
");
assert_snapshot!(readdir_snapshot(&mock_typeshed, "./stdlib/"), @r"
assert_snapshot!(readdir_snapshot(&mock_typeshed, "./stdlib/"), @"
vendored://stdlib/asyncio/
vendored://stdlib/functools.pyi
");

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/comments/shebang.rs
expression: "ShebangDirective::try_extract(source)"
snapshot_kind: text
---
None

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/comments/shebang.rs
expression: "ShebangDirective::try_extract(source)"
snapshot_kind: text
---
None

View File

@@ -1,7 +1,6 @@
---
source: crates/ruff_linter/src/comments/shebang.rs
expression: "ShebangDirective::try_extract(source)"
snapshot_kind: text
---
Some(
ShebangDirective(

View File

@@ -1,7 +1,6 @@
---
source: crates/ruff_linter/src/comments/shebang.rs
expression: "ShebangDirective::try_extract(source)"
snapshot_kind: text
---
Some(
ShebangDirective(

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/comments/shebang.rs
expression: "ShebangDirective::try_extract(source)"
snapshot_kind: text
---
None

View File

@@ -1,7 +1,6 @@
---
source: crates/ruff_linter/src/message/grouped.rs
expression: content
snapshot_kind: text
---
fib.py:
1:8 F401 `os` imported but unused

View File

@@ -1326,7 +1326,7 @@ mod tests {
fn noqa_all() {
let source = "# noqa";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1347,7 +1347,7 @@ mod tests {
fn noqa_no_code() {
let source = "# noqa:";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -1359,7 +1359,7 @@ mod tests {
fn noqa_no_code_invalid_suffix() {
let source = "# noqa: foo";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -1371,7 +1371,7 @@ mod tests {
fn noqa_no_code_trailing_content() {
let source = "# noqa: # Foo";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -1383,7 +1383,7 @@ mod tests {
fn malformed_code_1() {
let source = "# noqa: F";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -1422,7 +1422,7 @@ mod tests {
fn malformed_code_3() {
let source = "# noqa: RUF001F";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
InvalidCodeSuffix,
)
@@ -1492,7 +1492,7 @@ mod tests {
fn noqa_all_case_insensitive() {
let source = "# NOQA";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1625,7 +1625,7 @@ mod tests {
fn noqa_all_no_space() {
let source = "#noqa";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1704,7 +1704,7 @@ mod tests {
fn noqa_all_multi_space() {
let source = "# noqa";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1837,7 +1837,7 @@ mod tests {
fn noqa_all_leading_comment() {
let source = "# Some comment describing the noqa # noqa";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1916,7 +1916,7 @@ mod tests {
fn noqa_all_trailing_comment() {
let source = "# noqa # Some comment describing the noqa";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Ok(
Some(
NoqaLexerOutput {
@@ -1995,7 +1995,7 @@ mod tests {
fn noqa_invalid_codes() {
let source = "# noqa: unused-import, F401, some other code";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -2139,7 +2139,7 @@ mod tests {
fn noqa_code_invalid_code_suffix() {
let source = "# noqa: F401abc";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
InvalidCodeSuffix,
)
@@ -2151,7 +2151,7 @@ mod tests {
fn noqa_invalid_suffix() {
let source = "# noqa[F401]";
let directive = lex_inline_noqa(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
InvalidSuffix,
)
@@ -2163,7 +2163,7 @@ mod tests {
fn flake8_exemption_all() {
let source = "# flake8: noqa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2184,7 +2184,7 @@ mod tests {
fn flake8_noqa_no_code() {
let source = "# flake8: noqa:";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2196,7 +2196,7 @@ mod tests {
fn flake8_noqa_no_code_invalid_suffix() {
let source = "# flake8: noqa: foo";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2208,7 +2208,7 @@ mod tests {
fn flake8_noqa_no_code_trailing_content() {
let source = "# flake8: noqa: # Foo";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2220,7 +2220,7 @@ mod tests {
fn flake8_malformed_code_1() {
let source = "# flake8: noqa: F";
let directive = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -2259,7 +2259,7 @@ mod tests {
fn flake8_malformed_code_3() {
let source = "# flake8: noqa: RUF001F";
let directive = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
InvalidCodeSuffix,
)
@@ -2271,7 +2271,7 @@ mod tests {
fn ruff_exemption_all() {
let source = "# ruff: noqa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2292,7 +2292,7 @@ mod tests {
fn ruff_noqa_no_code() {
let source = "# ruff: noqa:";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2304,7 +2304,7 @@ mod tests {
fn ruff_noqa_no_code_invalid_suffix() {
let source = "# ruff: noqa: foo";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2316,7 +2316,7 @@ mod tests {
fn ruff_noqa_no_code_trailing_content() {
let source = "# ruff: noqa: # Foo";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
MissingCodes,
)
@@ -2328,7 +2328,7 @@ mod tests {
fn ruff_malformed_code_1() {
let source = "# ruff: noqa: F";
let directive = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
MissingCodes,
)
@@ -2367,7 +2367,7 @@ mod tests {
fn ruff_malformed_code_3() {
let source = "# ruff: noqa: RUF001F";
let directive = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(directive, @r"
assert_debug_snapshot!(directive, @"
Err(
InvalidCodeSuffix,
)
@@ -2379,7 +2379,7 @@ mod tests {
fn flake8_exemption_all_no_space() {
let source = "#flake8:noqa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2400,7 +2400,7 @@ mod tests {
fn ruff_exemption_all_no_space() {
let source = "#ruff:noqa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2619,7 +2619,7 @@ mod tests {
fn ruff_exemption_invalid_code_suffix() {
let source = "# ruff: noqa: F401abc";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Err(
InvalidCodeSuffix,
)
@@ -2685,7 +2685,7 @@ mod tests {
fn ruff_exemption_all_leading_comment() {
let source = "# Leading comment # ruff: noqa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2706,7 +2706,7 @@ mod tests {
fn ruff_exemption_all_trailing_comment() {
let source = "# ruff: noqa # Trailing comment";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2754,7 +2754,7 @@ mod tests {
fn ruff_exemption_all_trailing_comment_no_space() {
let source = "# ruff: noqa# Trailing comment";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2775,7 +2775,7 @@ mod tests {
fn ruff_exemption_all_trailing_comment_no_hash() {
let source = "# ruff: noqa Trailing comment";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2823,7 +2823,7 @@ mod tests {
fn flake8_exemption_all_case_insensitive() {
let source = "# flake8: NoQa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {
@@ -2844,7 +2844,7 @@ mod tests {
fn ruff_exemption_all_case_insensitive() {
let source = "# ruff: NoQa";
let exemption = lex_file_exemption(TextRange::up_to(source.text_len()), source);
assert_debug_snapshot!(exemption, @r"
assert_debug_snapshot!(exemption, @"
Ok(
Some(
NoqaLexerOutput {

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_async/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs
snapshot_kind: text
---

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
assertion_line: 50
---
G004 Logging statement uses f-string
--> G004_implicit_concat.py:6:10

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
snapshot_kind: text
---

View File

@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs
assertion_line: 71
---
G004 [*] Logging statement uses f-string
--> G004_implicit_concat.py:6:10

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs
snapshot_kind: text
---

View File

@@ -1,5 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs
snapshot_kind: text
---

Some files were not shown because too many files have changed in this diff Show More