Skip to content

Commit 8b3da18

Browse files
authored
refactor: remove unnecessary string hashes (#13250)
1 parent c173ec5 commit 8b3da18

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

crates/red_knot_python_semantic/src/semantic_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ class C[T]:
10271027
}
10281028

10291029
let TestCase { db, file } = test_case(
1030-
r#"
1030+
r"
10311031
class Test:
10321032
def foo():
10331033
def bar():
@@ -1036,7 +1036,7 @@ class Test:
10361036
pass
10371037
10381038
def x():
1039-
pass"#,
1039+
pass",
10401040
);
10411041

10421042
let index = semantic_index(&db, file);

crates/ruff/tests/format.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,18 @@ fn docstring_options() -> Result<()> {
326326
let ruff_toml = tempdir.path().join("ruff.toml");
327327
fs::write(
328328
&ruff_toml,
329-
r#"
329+
r"
330330
[format]
331331
docstring-code-format = true
332332
docstring-code-line-length = 20
333-
"#,
333+
",
334334
)?;
335335

336336
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
337337
.args(["format", "--config"])
338338
.arg(&ruff_toml)
339339
.arg("-")
340-
.pass_stdin(r#"
340+
.pass_stdin(r"
341341
def f(x):
342342
'''
343343
Something about `f`. And an example:
@@ -357,7 +357,7 @@ def f(x):
357357
>>> foo, bar, quux = this_is_a_long_line(lion, hippo, lemur, bear)
358358
'''
359359
pass
360-
"#), @r###"
360+
"), @r###"
361361
success: true
362362
exit_code: 0
363363
----- stdout -----
@@ -509,9 +509,9 @@ fn syntax_error() -> Result<()> {
509509

510510
fs::write(
511511
tempdir.path().join("main.py"),
512-
r#"
512+
r"
513513
from module import =
514-
"#,
514+
",
515515
)?;
516516

517517
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))

crates/ruff/tests/integration_test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ fn check_default_files() -> Result<()> {
158158
let tempdir = TempDir::new()?;
159159
fs::write(
160160
tempdir.path().join("foo.py"),
161-
r#"
161+
r"
162162
import foo # unused import
163-
"#,
163+
",
164164
)?;
165165
fs::write(
166166
tempdir.path().join("bar.py"),
167-
r#"
167+
r"
168168
import bar # unused import
169-
"#,
169+
",
170170
)?;
171171

172172
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
@@ -906,10 +906,10 @@ fn full_output_preview_config() -> Result<()> {
906906
let pyproject_toml = tempdir.path().join("pyproject.toml");
907907
fs::write(
908908
&pyproject_toml,
909-
r#"
909+
r"
910910
[tool.ruff]
911911
preview = true
912-
"#,
912+
",
913913
)?;
914914
let mut cmd = RuffCheck::default().config(&pyproject_toml).build();
915915
assert_cmd_snapshot!(cmd.pass_stdin("l = 1"), @r###"

crates/ruff_linter/src/rules/ruff/rules/missing_fstring_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub struct MissingFStringSyntax;
6161
impl AlwaysFixableViolation for MissingFStringSyntax {
6262
#[derive_message_formats]
6363
fn message(&self) -> String {
64-
format!(r#"Possible f-string without an `f` prefix"#)
64+
format!(r"Possible f-string without an `f` prefix")
6565
}
6666

6767
fn fix_title(&self) -> String {

crates/ruff_python_formatter/tests/normalizer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Transformer for Normalizer {
6262
fn visit_string_literal(&self, string_literal: &mut ast::StringLiteral) {
6363
static STRIP_DOC_TESTS: Lazy<Regex> = Lazy::new(|| {
6464
Regex::new(
65-
r#"(?mx)
65+
r"(?mx)
6666
(
6767
# strip doctest PS1 prompt lines
6868
^\s*>>>\s.*(\n|$)
@@ -71,7 +71,7 @@ impl Transformer for Normalizer {
7171
# Also handles the case of an empty ... line.
7272
^\s*\.\.\.((\n|$)|\s.*(\n|$))
7373
)+
74-
"#,
74+
",
7575
)
7676
.unwrap()
7777
});
@@ -80,11 +80,11 @@ impl Transformer for Normalizer {
8080
// impossible) to detect a reStructuredText block with a simple
8181
// regex. So we just look for the start of a block and remove
8282
// everything after it. Talk about a hammer.
83-
Regex::new(r#"::(?s:.*)"#).unwrap()
83+
Regex::new(r"::(?s:.*)").unwrap()
8484
});
8585
static STRIP_MARKDOWN_BLOCKS: Lazy<Regex> = Lazy::new(|| {
8686
// This covers more than valid Markdown blocks, but that's OK.
87-
Regex::new(r#"(```|~~~)\p{any}*(```|~~~|$)"#).unwrap()
87+
Regex::new(r"(```|~~~)\p{any}*(```|~~~|$)").unwrap()
8888
});
8989

9090
// Start by (1) stripping everything that looks like a code

0 commit comments

Comments
 (0)