Fix function signatures in PEP 677 (#2243)

The `flat_map` function is passing the function first in its calls, so the definition should reflect the same.
This commit is contained in:
Tushar Sadhwani 2022-01-17 23:13:14 +05:30 committed by GitHub
parent d927d9d4a6
commit 9c8b47c102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ like tab completion, static analysis tooling, and code review.
Consider the following untyped code:: Consider the following untyped code::
def flat_map(l, func): def flat_map(func, l):
out = [] out = []
for element in l: for element in l:
out.extend(func(element)) out.extend(func(element))
@ -58,8 +58,8 @@ We can add types to this example to detect the runtime error::
from typing import Callable from typing import Callable
def flat_map( def flat_map(
l: list[int], func: Callable[[int], list[int]],
func: Callable[[int], list[int]] l: list[int]
) -> list[int]: ) -> list[int]:
.... ....
@ -91,8 +91,8 @@ the benefits of static typing. For example, they might write this::
from typing import Callable from typing import Callable
def flat_map( def flat_map(
l: list[int], func: Callable[..., Any],
func: Callable[..., Any] l: list[int]
) -> list[int]: ) -> list[int]:
.... ....
@ -108,8 +108,8 @@ type checkers to find the bug.
With our proposal, the example looks like this:: With our proposal, the example looks like this::
def flat_map( def flat_map(
l: list[int],
func: (int) -> list[int], func: (int) -> list[int],
l: list[int]
) -> list[int]: ) -> list[int]:
out = [] out = []
for element in l: for element in l: