Skip to content
Open
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
2 changes: 1 addition & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3444,7 +3444,7 @@ def compute_dependencies(self) -> None:
# Every module implicitly depends on builtins.
if self.id != "builtins":
self.add_dependency("builtins")
if self.tree.uses_template_strings:
if self.tree.uses_template_strings and self.options.python_version >= (3, 14):
self.add_dependency("string.templatelib")

self.check_blockers() # Can fail due to bogus relative imports
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-python314.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ a = t"foobar"
a = t"{'foobar'}"
[builtins fixtures/f_string.pyi]

[case testTemplateStringBelowTargetDoesNotImportTemplatelib]
# flags: --python-version=3.13 --native-parser
t"hello {1}" # E: T-strings: requires Python 3.14 or newer (current target: Python 3.13)

[case testTemplateStringWithoutExplicitImport]
reveal_type(t"implicit import works") # N: Revealed type is "string.templatelib.Template"
[builtins fixtures/f_string.pyi]
Expand Down
Loading