Skip to content

Commit 2190362

Browse files
committed
{Template,Interpolation}.__init__ --> __new__
I can't believe I didn't catch this in any of my zillion previous re-reads. Sheesh!
1 parent b59421b commit 2190362

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

peps/pep-0750.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Template strings evaluate to an instance of a new type, ``templatelib.Template``
146146
class Template:
147147
args: tuple[str | Interpolation, ...]
148148
149-
def __init__(self, *args: str | Interpolation):
149+
def __new__(cls, *args: str | Interpolation):
150150
...
151151
152152
@property
@@ -196,8 +196,8 @@ Like ``Template``, it is a new class found in the ``templatelib`` module:
196196
197197
__match_args__ = ("value", "expr", "conv", "format_spec")
198198
199-
def __init__(
200-
self,
199+
def __new__(
200+
cls,
201201
value: object,
202202
expr: str,
203203
conv: Literal["a", "r", "s"] | None = None,
@@ -590,9 +590,9 @@ different values.
590590

591591
Interleaving is an invariant maintained by the ``Template`` class. Developers can
592592
take advantage of it but they are not required to themselves maintain it.
593-
Specifically, ``Template.__init__()`` can be called with ``str`` and
594-
``Interpolation`` instances in *any* order; the constructor will "interleave" them
595-
as necessary before assigning them to ``args``.
593+
Specifically, a ``Template`` can be constructed with ``str`` and
594+
``Interpolation`` instances in *any* order; they will automatically be
595+
"interleaved" as necessary before ``args`` is assigned.
596596

597597

598598
Examples

0 commit comments

Comments
 (0)