Skip to content

Commit

Permalink
[ruff] Skip RUF001 diagnostics when visiting string type definitions (
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Feb 12, 2025
1 parent a9671e7 commit c31352f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ class Labware:

# Implicit string concatenation
x = "𝐁ad" f"𝐁ad string"

from typing import Literal
x: '''"""'Literal["ﮨ"]'"""'''
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ pub(crate) fn ambiguous_unicode_character_comment(

/// RUF001, RUF002
pub(crate) fn ambiguous_unicode_character_string(checker: &Checker, string_like: StringLike) {
let context = if checker.semantic().in_pep_257_docstring() {
let semantic = checker.semantic();

if semantic.in_string_type_definition() {
return;
}

let context = if semantic.in_pep_257_docstring() {
Context::Docstring
} else {
Context::String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,22 @@ confusables.py:58:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD
57 | # Implicit string concatenation
58 | x = "𝐁ad" f"𝐁ad string"
| ^ RUF001
59 |
60 | from typing import Literal
|

confusables.py:58:13: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)?
|
57 | # Implicit string concatenation
58 | x = "𝐁ad" f"𝐁ad string"
| ^ RUF001
59 |
60 | from typing import Literal
|

confusables.py:61:20: RUF001 String contains ambiguous `` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)?
|
60 | from typing import Literal
61 | x: '''"""'Literal[""]'"""'''
| ^ RUF001
|
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@ confusables.py:58:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD
57 | # Implicit string concatenation
58 | x = "𝐁ad" f"𝐁ad string"
| ^ RUF001
59 |
60 | from typing import Literal
|

confusables.py:58:13: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)?
|
57 | # Implicit string concatenation
58 | x = "𝐁ad" f"𝐁ad string"
| ^ RUF001
59 |
60 | from typing import Literal
|

confusables.py:61:20: RUF001 String contains ambiguous `` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)?
|
60 | from typing import Literal
61 | x: '''"""'Literal[""]'"""'''
| ^ RUF001
|

0 comments on commit c31352f

Please sign in to comment.