Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 696: Add section on binding rules #3427

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions peps/pep-0696.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------

Expand Down