Skip to content
Open
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
21 changes: 10 additions & 11 deletions peps/pep-0718.rst
Original file line number Diff line number Diff line change
Expand Up @@ -839,22 +839,21 @@ Reference Implementation
branch. It predates ``types.FunctionGenericAlias`` (it returns a plain
``types.GenericAlias``) and does not yet cover ``MethodWrapperType``.
* `python/mypy#21880 <https://github.com/python/mypy/pull/21880>`__: a type checker
prototype of the behaviour specified here, behind
``--enable-incomplete-feature=SubscriptableFunctions``. It confirmed that
``ParamSpec``, ``TypeVarTuple`` and type parameter defaults can follow the rules for
generic classes by reusing the same code, and implements the overload filtering
described above.
prototype behind ``--enable-incomplete-feature=SubscriptableFunctions``.
It implements function subscription, including overload filtering, method
binding, type parameter defaults, ``ParamSpec`` and ``TypeVarTuple`` support,
and the Python 3.16 version check.
* `python/mypy#21881 <https://github.com/python/mypy/pull/21881>`__: a variant of the
prototype that only allows subscripting callables traceable to a ``def`` (see
`Rejected Ideas`_). It cannot be fully sound either, since type checkers have to
assume that decorators preserve the kind of object they wrap.

The following rules are not yet implemented in either prototype: reporting unsolvable
type parameters at the call instead of the definition, not reporting overloads that
differ only in type parameter bounds as overlapping, the consistency rule for overload
implementations, the Python version check, and keeping return-only type parameters
through ``ParamSpec`` decorators (mypy currently solves them to ``Never``, so a
``contextmanager`` function like ``session`` above cannot be subscripted).
The prototypes are experimental. The mypy prototype in
`python/mypy#21880 <https://github.com/python/mypy/pull/21880>`__
has been updated to address the typing rules specified here, with regression
tests. The stricter variant in
`python/mypy#21881 <https://github.com/python/mypy/pull/21881>`__
has not received these updates. The cpython prototype has not yet been updated.

Rejected Ideas
--------------
Expand Down
Loading