Skip to content

MyPy fails on Python 3.14 PEP 750 template string (tstring, t-string), e.g. t'{42}' #19329

Open
@Dutcho

Description

@Dutcho

Crash Report

MyPy (PyPI version and latest master from GitHub) fails on Python 3.14 PEP 750 template strings, e.g. t'{42}'.

I guess this is work in progress, while MyPy catches up with CPython. An error message like "MyPy doesn't support template strings yet" would be user friendlier. Therefore, and as requested ("Please report a bug"), creating this issue.

Traceback

(playground314) > py -V
Python 3.14.0b3

(playground314) > more x.py
t'{42}'

(playground314) > mypy x.py --show-traceback
x.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.17.0+dev.16e99de5376464beaa2cf086c1cd3dc5d26a791a
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "<dir>\.venv\Scripts\mypy.exe\__main__.py", line 10, in <module>
    sys.exit(console_entry())
  File "<dir>\.venv\Lib\site-packages\mypy\__main__.py", line 15, in console_entry
    main()
  File "<dir>\.venv\Lib\site-packages\mypy\main.py", line 127, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "<dir>\.venv\Lib\site-packages\mypy\main.py", line 211, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 191, in build
    result = _build(
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 267, in _build
    graph = dispatch(sources, manager, stdout)
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 2886, in dispatch
    graph = load_graph(sources, manager)
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 3072, in load_graph
    st = State(
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 1993, in __init__
    self.parse_file(temporary=temporary)
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 2133, in parse_file
    with self.wrap_context():
  File "C:\Program Files\Python314\Lib\contextlib.py", line 162, in __exit__
    self.gen.throw(value)
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 2062, in wrap_context
    yield
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 2171, in parse_file
    self.tree = manager.parse_file(
                ~~~~~~~~~~~~~~~~~~^
        self.id,
        ^^^^^^^^
    ...<3 lines>...
        options=self.options,
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "<dir>\.venv\Lib\site-packages\mypy\build.py", line 840, in parse_file
    tree = parse(source, path, id, self.errors, options=options)
  File "<dir>\.venv\Lib\site-packages\mypy\parse.py", line 27, in parse
    tree = mypy.fastparse.parse(source, fnam=fnam, module=module, errors=errors, options=options)
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 241, in parse
    ).visit(ast)
      ~~~~~^^^^^
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 435, in visit
    return visitor(node)
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 894, in visit_Module
    body = self.fix_function_overloads(self.translate_stmt_list(mod.body, ismodule=True))
                                       ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 509, in translate_stmt_list
    node = self.visit(stmt)
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 435, in visit
    return visitor(node)
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 1459, in visit_Expr
    value = self.visit(n.value)
  File "<dir>\.venv\Lib\site-packages\mypy\fastparse.py", line 432, in visit
    visitor = getattr(self, method)
AttributeError: 'ASTConverter' object has no attribute 'visit_TemplateStr'
x.py: : note: use --pdb to drop into pdb

To Reproduce

Run mypy x.py with x.py containing f'{42}'.

Your Environment

  • Mypy version used: GitHub master 1.17.0+dev
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.14.0b3 in virtual environment .venv
  • Operating system and version: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy