PEP 696: Add section on binding rules (#3427)
This commit is contained in:
parent
2868fe9c84
commit
94ac129495
|
@ -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
|
||||
--------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue