@@ -5484,6 +5484,114 @@ def postinit(self, *, patterns: list[Pattern]) -> None:
54845484 self .patterns = patterns
54855485
54865486
5487+ class TemplateStr (NodeNG ):
5488+ """Class representing an :class:`ast.TemplateStr` node.
5489+
5490+ >>> import astroid
5491+ >>> node = astroid.extract_node('t"{name} finished {place!s}"')
5492+ >>> node
5493+ <TemplateStr l.1 at 0x103b7aa50>
5494+ """
5495+
5496+ _astroid_fields = ("values" ,)
5497+
5498+ def __init__ (
5499+ self ,
5500+ lineno : int | None = None ,
5501+ col_offset : int | None = None ,
5502+ parent : NodeNG | None = None ,
5503+ * ,
5504+ end_lineno : int | None = None ,
5505+ end_col_offset : int | None = None ,
5506+ ) -> None :
5507+ self .values : list [NodeNG ]
5508+ super ().__init__ (
5509+ lineno = lineno ,
5510+ col_offset = col_offset ,
5511+ end_lineno = end_lineno ,
5512+ end_col_offset = end_col_offset ,
5513+ parent = parent ,
5514+ )
5515+
5516+ def postinit (self , * , values : list [NodeNG ]) -> None :
5517+ self .values = values
5518+
5519+ def get_children (self ) -> Iterator [NodeNG ]:
5520+ yield from self .values
5521+
5522+
5523+ class Interpolation (NodeNG ):
5524+ """Class representing an :class:`ast.Interpolation` node.
5525+
5526+ >>> import astroid
5527+ >>> node = astroid.extract_node('t"{name} finished {place!s}"')
5528+ >>> node
5529+ <TemplateStr l.1 at 0x103b7aa50>
5530+ >>> node.values[0]
5531+ <Interpolation l.1 at 0x103b7acf0>
5532+ >>> node.values[2]
5533+ <Interpolation l.1 at 0x10411e5d0>
5534+ """
5535+
5536+ _astroid_fields = ("value" , "format_spec" )
5537+ _other_fields = ("str" , "conversion" )
5538+
5539+ def __init__ (
5540+ self ,
5541+ lineno : int | None = None ,
5542+ col_offset : int | None = None ,
5543+ parent : NodeNG | None = None ,
5544+ * ,
5545+ end_lineno : int | None = None ,
5546+ end_col_offset : int | None = None ,
5547+ ) -> None :
5548+ self .value : NodeNG
5549+ """Any expression node."""
5550+
5551+ self .str : str
5552+ """Text of the interpolation expression."""
5553+
5554+ self .conversion : int
5555+ """The type of formatting to be applied to the value.
5556+
5557+ .. seealso::
5558+ :class:`ast.Interpolation`
5559+ """
5560+
5561+ self .format_spec : JoinedStr | None = None
5562+ """The formatting to be applied to the value.
5563+
5564+ .. seealso::
5565+ :class:`ast.Interpolation`
5566+ """
5567+
5568+ super ().__init__ (
5569+ lineno = lineno ,
5570+ col_offset = col_offset ,
5571+ end_lineno = end_lineno ,
5572+ end_col_offset = end_col_offset ,
5573+ parent = parent ,
5574+ )
5575+
5576+ def postinit (
5577+ self ,
5578+ * ,
5579+ value : NodeNG ,
5580+ str : str , # pylint: disable=redefined-builtin
5581+ conversion : int = - 1 ,
5582+ format_spec : JoinedStr | None = None ,
5583+ ) -> None :
5584+ self .value = value
5585+ self .str = str
5586+ self .conversion = conversion
5587+ self .format_spec = format_spec
5588+
5589+ def get_children (self ) -> Iterator [NodeNG ]:
5590+ yield self .value
5591+ if self .format_spec :
5592+ yield self .format_spec
5593+
5594+
54875595# constants ##############################################################
54885596
54895597# The _proxied attribute of all container types (List, Tuple, etc.)
0 commit comments