From 94ac1294957bd8c21b113c235be44fd0118dd7d7 Mon Sep 17 00:00:00 2001 From: James Hilton-Balfe Date: Thu, 14 Sep 2023 14:33:43 +0100 Subject: [PATCH] PEP 696: Add section on binding rules (#3427) --- peps/pep-0696.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/peps/pep-0696.rst b/peps/pep-0696.rst index ce1678adc..7e8f7f1e1 100644 --- a/peps/pep-0696.rst +++ b/peps/pep-0696.rst @@ -382,6 +382,21 @@ Function Defaults functions as ensuring the ``default`` is returned in every code path where the ``TypeVarLike`` can go unsolved is too hard to implement. +Binding rules +------------- + +``TypeVarLikes`` defaults should be bound by attribute access +(including call and subscript). + +.. code-block:: python + + class Foo[T = int]: + def meth(self) -> Self: + return self + + reveal_type(Foo.meth) # type is (self: Foo[int]) -> Foo[int] + + Implementation --------------