astroid icon indicating copy to clipboard operation
astroid copied to clipboard

TemplateString: Proper inference similar to JoinedStr._infer and additional tests for the as_string()

Open jacobtylerwalls opened this issue 7 months ago • 1 comments

Fix this error in pylint with 3.14:

  • AttributeError: 'TreeRebuilder' object has no attribute 'visit_templatestr'

https://docs.python.org/3.14/library/ast.html#ast.TemplateStr

jacobtylerwalls avatar Jul 28 '25 11:07 jacobtylerwalls

Initial support added in #2793 and released as part of 4.0.0b2.

Open issues

  • Additional tests for the as_string() logic. The basics work but there might be a lot of edge case which need to be handled properly. The existing f-string tests could provide a good starting point. https://github.com/pylint-dev/astroid/blob/f9e109eedf75fcc900e9209a9d42ec516599e301/tests/test_nodes.py#L295-L307
  • Add proper inference similar to JoinedStr._infer. https://github.com/pylint-dev/astroid/blob/f9e109eedf75fcc900e9209a9d42ec516599e301/astroid/nodes/node_classes.py#L4775-L4781

cdce8p avatar Aug 06 '25 20:08 cdce8p