Skip to content

Commit 11917c4

Browse files
committed
show new glob in warning
1 parent 7c86490 commit 11917c4

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

crates/ruff/tests/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2165,15 +2165,15 @@ fn cookiecutter_globbing() -> Result<()> {
21652165
--- {{cookiecutter.repo_name}}/tests/maintest.py
21662166
+++ {{cookiecutter.repo_name}}/tests/maintest.py
21672167
@@ -1,3 +1,3 @@
2168-
import foo
2169-
import bar
2168+
import foo
2169+
import bar
21702170
-import foo
21712171
/ No newline at end of file
21722172
+import foo
21732173
21742174
21752175
----- stderr -----
2176-
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces (`{}`)
2176+
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
21772177
1 file would be reformatted
21782178
"#);
21792179
});

crates/ruff/tests/lint.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2729,14 +2729,14 @@ fn cookiecutter_globbing() -> Result<()> {
27292729
.args(STDIN_BASE_OPTIONS)
27302730
.arg("--select=F811")
27312731
.current_dir(tempdir.path()), @r#"
2732-
success: true
2733-
exit_code: 0
2734-
----- stdout -----
2735-
All checks passed!
2732+
success: true
2733+
exit_code: 0
2734+
----- stdout -----
2735+
All checks passed!
27362736
2737-
----- stderr -----
2738-
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces (`{}`)
2739-
"#);
2737+
----- stderr -----
2738+
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
2739+
"#);
27402740
});
27412741

27422742
// after removing the config file with the ignore, F811 applies, so the glob worked above

crates/ruff_linter/src/settings/types.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,11 @@ where
656656
pub fn try_glob_new(s: &str) -> Result<Glob> {
657657
match Glob::new(s) {
658658
Err(e) if *e.kind() == globset::ErrorKind::NestedAlternates => {
659-
log::warn!("Error parsing original glob: `{s:?}`, trying with escaped braces (`{{}}`)");
660-
let s = s.replace("{{", "[{][{]").replace("}}", "[}][}]");
661-
Ok(Glob::new(&s)?)
659+
let new = s.replace("{{", "[{][{]").replace("}}", "[}][}]");
660+
log::warn!(
661+
"Error parsing original glob: `{s:?}`, trying with escaped braces: `{new:?}`"
662+
);
663+
Ok(Glob::new(&new)?)
662664
}
663665
glob => Ok(glob?),
664666
}

0 commit comments

Comments
 (0)