Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 22 additions & 0 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def ast3_parse(
ast_TypeVar = Any
ast_TypeVarTuple = Any

if sys.version_info >= (3, 14):
ast_TemplateStr = ast3.TemplateStr
ast_Interpolation = ast3.Interpolation
else:
ast_TemplateStr = Any
ast_Interpolation = Any

N = TypeVar("N", bound=Node)

# There is no way to create reasonable fallbacks at this stage,
Expand Down Expand Up @@ -1705,6 +1712,21 @@ def visit_FormattedValue(self, n: ast3.FormattedValue) -> Expression:
)
return self.set_line(result_expression, n)

# TemplateStr(expr* values)
def visit_TemplateStr(self, n: ast_TemplateStr) -> Expression:
self.fail(
ErrorMessage("PEP 750 template strings are not yet supported"),
n.lineno,
n.col_offset,
blocker=False,
)
e = TempNode(AnyType(TypeOfAny.from_error))
return self.set_line(e, n)

# Interpolation(expr value, constant str, int conversion, expr? format_spec)
def visit_Interpolation(self, n: ast_Interpolation) -> Expression:
assert False, "Unreachable"

# Attribute(expr value, identifier attr, expr_context ctx)
def visit_Attribute(self, n: Attribute) -> MemberExpr | SuperExpr:
value = n.value
Expand Down
2 changes: 2 additions & 0 deletions mypy/test/testcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
typecheck_files.remove("check-python312.test")
if sys.version_info < (3, 13):
typecheck_files.remove("check-python313.test")
if sys.version_info < (3, 14):
typecheck_files.remove("check-python314.test")


class TypeCheckSuite(DataSuite):
Expand Down
4 changes: 4 additions & 0 deletions mypy/test/testparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ParserSuite(DataSuite):
files.remove("parse-python312.test")
if sys.version_info < (3, 13):
files.remove("parse-python313.test")
if sys.version_info < (3, 14):
files.remove("parse-python314.test")

def run_case(self, testcase: DataDrivenTestCase) -> None:
test_parser(testcase)
Expand All @@ -46,6 +48,8 @@ def test_parser(testcase: DataDrivenTestCase) -> None:
options.python_version = (3, 12)
elif testcase.file.endswith("python313.test"):
options.python_version = (3, 13)
elif testcase.file.endswith("python314.test"):
options.python_version = (3, 14)
else:
options.python_version = defaults.PYTHON3_VERSION

Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/check-python314.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[case testTemplateString]
reveal_type(t"mypy") # E: PEP 750 template strings are not yet supported \
# N: Revealed type is "Any"
5 changes: 5 additions & 0 deletions test-data/unit/parse-python314.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[case testTemplateString]
x = 'mypy'
t'Hello {x}'
[out]
main:2: error: PEP 750 template strings are not yet supported
Loading