Skip to content

Commit a796f5d

Browse files
committed
Fix further sphinx warnings
1 parent fcd74e6 commit a796f5d

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Doc/library/string.templatelib.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
.. seealso::
1313

14-
:ref:`f-strings` -- Format strings (f-strings)
14+
:ref:`Format strings <f-strings>`
1515

1616

1717
.. _templatelib-template:
@@ -124,7 +124,6 @@ It is also possible to create a :class:`!Template` directly, using its construct
124124
:type value: Literal["a", "r", "s"] | None
125125

126126
:param format_spec: An optional, arbitrary string used as the :ref:`format specification <formatspec>` to present the value.
127-
:type expression: str = ""
128127

129128
The :class:`!Interpolation` type represents an expression inside a template string. It is shallow immutable -- its attributes cannot be reassigned.
130129

@@ -154,3 +153,32 @@ It is also possible to create a :class:`!Template` directly, using its construct
154153

155154
:returns: A tuple of the attributes to use for structural pattern matching.
156155
:rtype: (Literal["value"], Literal["expression"], Literal["conversion"], Literal["format_spec"])
156+
157+
158+
.. property:: value
159+
160+
:returns: The evaluated value of the interpolation.
161+
:rtype: object
162+
163+
.. property:: expression
164+
165+
:returns: The original text of the interpolation's Python expression if the interpolation was created from a t-string literal
166+
:rtype: str
167+
168+
The :attr:`~Interpolation.expression` is the original text of the interpolation's Python expression, if the interpolation was created from a t-string literal. Developers creating
169+
interpolations manually should either set this to an empty
170+
string or choose a suitable valid python expression.
171+
172+
.. property:: conversion
173+
174+
:returns: The conversion to apply to the value, one of "a", "r", or "s", or None.
175+
:rtype: Literal["a", "r", "s"] | None
176+
177+
The :attr:`~Interpolation.conversion` is the optional conversion to apply to the value. This is one of "a", "r", or "s", or None if no conversion is specified.
178+
179+
.. property:: format_spec
180+
181+
:returns: The format specification to apply to the value.
182+
:rtype: str
183+
184+
The :attr:`~Interpolation.format_spec` is an optional, arbitrary string used as the format specification to present the value. This is similar to the format specification used in :ref:`format strings <formatstrings>`, but it is not limited to a specific set of formats.

0 commit comments

Comments
 (0)