Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update run-strings.test
  • Loading branch information
BobTheBuidler authored Sep 16, 2025
commit c68965fa5652505601106dd55293aa29b3f64345
8 changes: 5 additions & 3 deletions mypyc/test-data/run-strings.test
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,16 @@ def test_basics() -> None:
[case testFStrings]
import decimal
from datetime import datetime
from typing import Final

var = 'mypyc'
num = 20
final_known_at_compile_time: Final = 'hello'

def final_value_setter() -> str:
return 'hello'
return 'goodbye'

final_var: Final = final_value_setter()
final_unknown_at_compile_time: Final = final_value_setter()

def test_fstring_basics() -> None:
assert f'Hello {var}, this is a test' == "Hello mypyc, this is a test"
Expand Down Expand Up @@ -456,7 +458,7 @@ def test_fstring_basics() -> None:
inf_num = float('inf')
assert f'{nan_num}, {inf_num}' == 'nan, inf'

assert f'{final_var}' == 'hello'
assert f'{final_known_at_compile_time} {final_unknown_at_compile_time}' == 'hello goodbye'

# F-strings would be translated into ''.join[string literals, format method call, ...] in mypy AST.
# Currently we are using a str.join specializer for f-string speed up. We might not cover all cases
Expand Down
Loading