[pylint] Use lowercase hex characters to match the formatter (PLE2513) (#19808)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run

PLE2513 --fix changes ESC and SUB to uppercase hexadecimal values such
as \x1B while the formatter changes them to lowercase \x1b

<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->

---------

Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
This commit is contained in:
ember91 2025-08-08 14:25:11 +02:00 committed by GitHub
parent fd35435281
commit 50e1ecc086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View file

@ -48,7 +48,7 @@ impl Violation for InvalidCharacterBackspace {
/// Control characters are displayed differently by different text editors and
/// terminals.
///
/// By using the `\x1A` sequence in lieu of the `SUB` control character, the
/// By using the `\x1a` sequence in lieu of the `SUB` control character, the
/// string will contain the same value, but will render visibly in all editors.
///
/// ## Example
@ -68,7 +68,7 @@ impl Violation for InvalidCharacterSub {
#[derive_message_formats]
fn message(&self) -> String {
"Invalid unescaped character SUB, use \"\\x1A\" instead".to_string()
"Invalid unescaped character SUB, use \"\\x1a\" instead".to_string()
}
fn fix_title(&self) -> Option<String> {
@ -83,7 +83,7 @@ impl Violation for InvalidCharacterSub {
/// Control characters are displayed differently by different text editors and
/// terminals.
///
/// By using the `\x1B` sequence in lieu of the `SUB` control character, the
/// By using the `\x1b` sequence in lieu of the `ESC` control character, the
/// string will contain the same value, but will render visibly in all editors.
///
/// ## Example
@ -103,7 +103,7 @@ impl Violation for InvalidCharacterEsc {
#[derive_message_formats]
fn message(&self) -> String {
"Invalid unescaped character ESC, use \"\\x1B\" instead".to_string()
"Invalid unescaped character ESC, use \"\\x1b\" instead".to_string()
}
fn fix_title(&self) -> Option<String> {
@ -191,7 +191,7 @@ pub(crate) fn invalid_string_characters(context: &LintContext, token: &Token, lo
_ => return,
};
for (column, match_) in text.match_indices(&['\x08', '\x1A', '\x1B', '\0', '\u{200b}']) {
for (column, match_) in text.match_indices(&['\x08', '\x1a', '\x1b', '\0', '\u{200b}']) {
let location = token.start() + TextSize::try_from(column).unwrap();
let c = match_.chars().next().unwrap();
let range = TextRange::at(location, c.text_len());
@ -209,12 +209,12 @@ pub(crate) fn invalid_string_characters(context: &LintContext, token: &Token, lo
"\\b",
context.report_diagnostic_if_enabled(InvalidCharacterBackspace, range),
),
'\x1A' => (
"\\x1A",
'\x1a' => (
"\\x1a",
context.report_diagnostic_if_enabled(InvalidCharacterSub, range),
),
'\x1B' => (
"\\x1B",
'\x1b' => (
"\\x1b",
context.report_diagnostic_if_enabled(InvalidCharacterEsc, range),
),
'\0' => (