Preserve raw string prefix and escapes (#15694)

## Summary

Fixes #9663 and also improves the fixes for
[RUF055](https://docs.astral.sh/ruff/rules/unnecessary-regular-expression/)
since regular expressions are often written as raw strings.

This doesn't include raw f-strings.

## Test Plan

Existing snapshots for RUF055 and PT009, plus a new `Generator` test and
a regression test for the reported `PIE810` issue.
This commit is contained in:
Brent Westbrook 2025-01-23 12:12:10 -05:00 committed by GitHub
parent 569060f46c
commit cffd1866ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 18 deletions

View file

@ -24,6 +24,14 @@ impl Quote {
}
}
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::Single => "'",
Self::Double => "\"",
}
}
#[must_use]
#[inline]
pub const fn opposite(self) -> Self {