Skip to content

Commit b5f0d92

Browse files
committed
t-strings do not have type str so no need to do anything here
1 parent 02f2a9c commit b5f0d92

8 files changed

Lines changed: 32 additions & 1 deletion

File tree

crates/ruff_linter/resources/test/fixtures/flake8_errmsg/EM.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,10 @@ def f_multi_line_string2():
8888
example="example"
8989
)
9090
)
91+
92+
93+
# Don't trigger for t-strings (it's a type error)
94+
def f_t_string():
95+
example = "example"
96+
raise RuntimeError(t"This is an {example} exception")
97+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
_(f"{'value'}")
2+
3+
# Don't trigger for t-strings
4+
_(t"{'value'}")

crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G004.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313

1414
info(f"{name}")
1515
info(f"{__name__}")
16+
17+
# Don't trigger for t-strings
18+
info(t"{name}")
19+
info(t"{__name__}")

crates/ruff_linter/resources/test/fixtures/pylint/single_string_slots.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ class Foo:
3333

3434
def __init__(self, bar):
3535
self.bar = bar
36+
37+
# This is a type error, out of scope for the rule
38+
class Foo:
39+
__slots__ = t"bar"
40+
41+
def __init__(self, bar):
42+
self.bar = bar
43+

crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,6 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi
278278
91 |+ raise RuntimeError(
279279
92 |+ msg
280280
93 |+ )
281+
91 94 |
282+
92 95 |
283+
93 96 | # Don't trigger for t-strings (it's a type error)

crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,6 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi
343343
91 |+ raise RuntimeError(
344344
92 |+ msg
345345
93 |+ )
346+
91 94 |
347+
92 95 |
348+
93 96 | # Don't trigger for t-strings (it's a type error)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs
3-
snapshot_kind: text
43
---
54
INT001.py:1:3: INT001 f-string is resolved before function call; consider `_("string %s") % arg`
65
|
76
1 | _(f"{'value'}")
87
| ^^^^^^^^^^^^ INT001
8+
2 |
9+
3 | # Don't trigger for t-strings
910
|

crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ G004.py:15:6: G004 Logging statement uses f-string
5252
14 | info(f"{name}")
5353
15 | info(f"{__name__}")
5454
| ^^^^^^^^^^^^^ G004
55+
16 |
56+
17 | # Don't trigger for t-strings
5557
|

0 commit comments

Comments
 (0)