refactor: remove unnecessary string hashes (#13250)

This commit is contained in:
Hamir Mahal 2024-09-18 10:08:59 -07:00 committed by GitHub
parent c173ec5bc7
commit 8b3da1867e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 19 deletions

View file

@ -1027,7 +1027,7 @@ class C[T]:
}
let TestCase { db, file } = test_case(
r#"
r"
class Test:
def foo():
def bar():
@ -1036,7 +1036,7 @@ class Test:
pass
def x():
pass"#,
pass",
);
let index = semantic_index(&db, file);

View file

@ -326,18 +326,18 @@ fn docstring_options() -> Result<()> {
let ruff_toml = tempdir.path().join("ruff.toml");
fs::write(
&ruff_toml,
r#"
r"
[format]
docstring-code-format = true
docstring-code-line-length = 20
"#,
",
)?;
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["format", "--config"])
.arg(&ruff_toml)
.arg("-")
.pass_stdin(r#"
.pass_stdin(r"
def f(x):
'''
Something about `f`. And an example:
@ -357,7 +357,7 @@ def f(x):
>>> foo, bar, quux = this_is_a_long_line(lion, hippo, lemur, bear)
'''
pass
"#), @r###"
"), @r###"
success: true
exit_code: 0
----- stdout -----
@ -509,9 +509,9 @@ fn syntax_error() -> Result<()> {
fs::write(
tempdir.path().join("main.py"),
r#"
r"
from module import =
"#,
",
)?;
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))

View file

@ -158,15 +158,15 @@ fn check_default_files() -> Result<()> {
let tempdir = TempDir::new()?;
fs::write(
tempdir.path().join("foo.py"),
r#"
r"
import foo # unused import
"#,
",
)?;
fs::write(
tempdir.path().join("bar.py"),
r#"
r"
import bar # unused import
"#,
",
)?;
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
@ -906,10 +906,10 @@ fn full_output_preview_config() -> Result<()> {
let pyproject_toml = tempdir.path().join("pyproject.toml");
fs::write(
&pyproject_toml,
r#"
r"
[tool.ruff]
preview = true
"#,
",
)?;
let mut cmd = RuffCheck::default().config(&pyproject_toml).build();
assert_cmd_snapshot!(cmd.pass_stdin("l = 1"), @r###"

View file

@ -61,7 +61,7 @@ pub struct MissingFStringSyntax;
impl AlwaysFixableViolation for MissingFStringSyntax {
#[derive_message_formats]
fn message(&self) -> String {
format!(r#"Possible f-string without an `f` prefix"#)
format!(r"Possible f-string without an `f` prefix")
}
fn fix_title(&self) -> String {

View file

@ -62,7 +62,7 @@ impl Transformer for Normalizer {
fn visit_string_literal(&self, string_literal: &mut ast::StringLiteral) {
static STRIP_DOC_TESTS: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r#"(?mx)
r"(?mx)
(
# strip doctest PS1 prompt lines
^\s*>>>\s.*(\n|$)
@ -71,7 +71,7 @@ impl Transformer for Normalizer {
# Also handles the case of an empty ... line.
^\s*\.\.\.((\n|$)|\s.*(\n|$))
)+
"#,
",
)
.unwrap()
});
@ -80,11 +80,11 @@ impl Transformer for Normalizer {
// impossible) to detect a reStructuredText block with a simple
// regex. So we just look for the start of a block and remove
// everything after it. Talk about a hammer.
Regex::new(r#"::(?s:.*)"#).unwrap()
Regex::new(r"::(?s:.*)").unwrap()
});
static STRIP_MARKDOWN_BLOCKS: Lazy<Regex> = Lazy::new(|| {
// This covers more than valid Markdown blocks, but that's OK.
Regex::new(r#"(```|~~~)\p{any}*(```|~~~|$)"#).unwrap()
Regex::new(r"(```|~~~)\p{any}*(```|~~~|$)").unwrap()
});
// Start by (1) stripping everything that looks like a code