Describe the Bug
Pyrefly misses type errors in fstrings.
It seems like it's not checking expressions in fstrings at all.
This code...
val1 = len(False)
msg1 = f"{len(False)}"
val2 = len(42)
msg2 = f"{len(42)}"
val3 = 2 + "Foo"
msg3 = f"{2 + 'Foo'}"
arr: list[int] = [1, 2, 3]
val4 = arr["foo"]
msg4 = f"{arr['foo']}"
... only produces errors on the val assignments, not the msg assignments with the same expressions wrapped in fstrings.
ERROR Argument `Literal[False]` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
--> test.py:1:12
|
1 | val1 = len(False)
| ^^^^^
|
Protocol `Sized` requires attribute `__len__`
ERROR Argument `Literal[42]` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
--> test.py:4:12
|
4 | val2 = len(42)
| ^^
|
Protocol `Sized` requires attribute `__len__`
ERROR `+` is not supported between `Literal[2]` and `Literal['Foo']` [unsupported-operation]
--> test.py:7:8
|
7 | val3 = 2 + "Foo"
| ^^^^^^^^^
|
Argument `Literal['Foo']` is not assignable to parameter `value` with type `int` in function `int.__add__`
ERROR Cannot index into `list[int]` [bad-index]
--> test.py:11:8
|
11 | val4 = arr["foo"]
| ^^^^^^^^^^
|
No matching overload found for function `list.__getitem__` called with arguments: (Literal['foo'])
Possible overloads:
(i: SupportsIndex, /) -> int [closest match]
(s: slice[Any, Any, Any], /) -> list[int]
INFO 4 errors
Sandbox Link
snipped in pyrefly sandbox
(Only applicable for extension issues) IDE Information
» python --version
Python 3.13.5
» pyrefly --version
pyrefly 0.55.0
[tool.pyrefly]
project-includes = ["**/*.py*", "**/*.ipynb"]
project-excludes = [".venv/**"]
search-path = ["."]
python-interpreter = ".venv/bin/python"
site-package-path = [".venv/lib/python3.13/site-packages"]
Describe the Bug
Pyrefly misses type errors in fstrings.
It seems like it's not checking expressions in fstrings at all.
This code...
... only produces errors on the
valassignments, not themsgassignments with the same expressions wrapped in fstrings.Sandbox Link
snipped in pyrefly sandbox
(Only applicable for extension issues) IDE Information