FormattedValue

class astroid.nodes.FormattedValue(lineno: int | None = None, col_offset: int | None = None, parent: NodeNG | None = None, *, end_lineno: int | None = None, end_col_offset: int | None = None)[source]

Bases: NodeNG

Class representing an ast.FormattedValue node.

Represents a PEP 498 format string.

>>> import astroid
>>> node = astroid.extract_node('f"Format {type_}"')
>>> node
<JoinedStr l.1 at 0x7f23b2e4ed30>
>>> node.values
[<Const.str l.1 at 0x7f23b2e4eda0>, <FormattedValue l.1 at 0x7f23b2e4edd8>]
conversion: int

The type of formatting to be applied to the value.

format_spec: JoinedStr | None

The formatting to be applied to the value.

get_children()[source]

Get the child nodes below this node.

postinit(*, value: NodeNG, conversion: int, format_spec: JoinedStr | None = None) None[source]

Do some setup after initialisation.

Parameters:
  • value – The value to be formatted into the string.

  • conversion – The type of formatting to be applied to the value.

  • format_spec (JoinedStr or None) – The formatting to be applied to the value.

value: NodeNG

The value to be formatted into the string.