PEP 696: Add section on binding rules (#3427)

This commit is contained in:
James Hilton-Balfe 2023-09-14 14:33:43 +01:00 committed by GitHub
parent 2868fe9c84
commit 94ac129495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -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
--------------