File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1248,6 +1248,7 @@ def _format_str_once(
12481248 for feature in {
12491249 Feature .PARENTHESIZED_CONTEXT_MANAGERS ,
12501250 Feature .UNPARENTHESIZED_EXCEPT_TYPES ,
1251+ Feature .T_STRINGS ,
12511252 }
12521253 if supports_feature (versions , feature )
12531254 }
@@ -1364,6 +1365,8 @@ def get_features_used( # noqa: C901
13641365 for n in node .pre_order ():
13651366 if n .type == token .FSTRING_START :
13661367 features .add (Feature .F_STRINGS )
1368+ elif n .type == token .TSTRING_START :
1369+ features .add (Feature .T_STRINGS )
13671370 elif (
13681371 n .type == token .RBRACE
13691372 and n .parent is not None
Original file line number Diff line number Diff line change @@ -52,9 +52,10 @@ class Feature(Enum):
5252 DEBUG_F_STRINGS = 16
5353 PARENTHESIZED_CONTEXT_MANAGERS = 17
5454 TYPE_PARAMS = 18
55- FSTRING_PARSING = 19
55+ # FSTRING_PARSING = 19 # unused
5656 TYPE_PARAM_DEFAULTS = 20
5757 UNPARENTHESIZED_EXCEPT_TYPES = 21
58+ T_STRINGS = 22
5859 FORCE_OPTIONAL_PARENTHESES = 50
5960
6061 # __future__ flags
@@ -165,7 +166,6 @@ class Feature(Enum):
165166 Feature .EXCEPT_STAR ,
166167 Feature .VARIADIC_GENERICS ,
167168 Feature .TYPE_PARAMS ,
168- Feature .FSTRING_PARSING ,
169169 },
170170 TargetVersion .PY313 : {
171171 Feature .F_STRINGS ,
@@ -185,7 +185,6 @@ class Feature(Enum):
185185 Feature .EXCEPT_STAR ,
186186 Feature .VARIADIC_GENERICS ,
187187 Feature .TYPE_PARAMS ,
188- Feature .FSTRING_PARSING ,
189188 Feature .TYPE_PARAM_DEFAULTS ,
190189 },
191190 TargetVersion .PY314 : {
@@ -206,9 +205,9 @@ class Feature(Enum):
206205 Feature .EXCEPT_STAR ,
207206 Feature .VARIADIC_GENERICS ,
208207 Feature .TYPE_PARAMS ,
209- Feature .FSTRING_PARSING ,
210208 Feature .TYPE_PARAM_DEFAULTS ,
211209 Feature .UNPARENTHESIZED_EXCEPT_TYPES ,
210+ Feature .T_STRINGS ,
212211 },
213212}
214213
Original file line number Diff line number Diff line change @@ -898,6 +898,9 @@ def test_get_features_used(self) -> None:
898898 self .check_features_used (
899899 "with ((a, ((b as c)))): pass" , {Feature .PARENTHESIZED_CONTEXT_MANAGERS }
900900 )
901+ self .check_features_used (
902+ "x = t'foo {f'bar'}'" , {Feature .T_STRINGS , Feature .F_STRINGS }
903+ )
901904
902905 def check_features_used (self , source : str , expected : set [Feature ]) -> None :
903906 node = black .lib2to3_parse (source )
You can’t perform that action at this time.
0 commit comments