-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved type inference for lambdas in the case where a parameter inc…
…ludes a default value and the expected type doesn't include that parameter. This improvement was suggested in the [mypy issue tracker](python/mypy#15459).
- Loading branch information
1 parent
8ce23eb
commit dbc283a
Showing
3 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This sample tests the case where a lambda includes one or more parameters | ||
# that accept a default value and the the expected type does not include | ||
# these parameters. In this case, the types of the extra parameters should | ||
# be inferred based on the default value type. | ||
|
||
# pyright: strict | ||
|
||
from typing import Callable | ||
|
||
|
||
def func1() -> list[Callable[[int], int]]: | ||
return [lambda x, i=i: i * x for i in range(5)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters