Commit 52b0470
authored
[red-knot] Synthesize a
## Summary
Currently this assertion fails on `main`, because we do not synthesize a
`__call__` attribute for Callable types:
```py
from typing import Protocol, Callable
from knot_extensions import static_assert, is_assignable_to
class Foo(Protocol):
def __call__(self, x: int, /) -> str: ...
static_assert(is_assignable_to(Callable[[int], str], Foo))
```
This PR fixes that.
See previous discussion about this in
astral-sh#16493 (comment) and
astral-sh#17682 (comment)
## Test Plan
Existing mdtests updated; a couple of new ones added.__call__ attribute for Callable types (astral-sh#17809)1 parent c4a0878 commit 52b0470
File tree
3 files changed
+24
-19
lines changed- crates/red_knot_python_semantic
- resources/mdtest
- annotations
- src
3 files changed
+24
-19
lines changedLines changed: 1 addition & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 303 | + | |
309 | 304 | | |
310 | 305 | | |
311 | 306 | | |
Lines changed: 19 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1476 | 1476 | | |
1477 | 1477 | | |
1478 | 1478 | | |
| 1479 | + | |
| 1480 | + | |
1479 | 1481 | | |
1480 | 1482 | | |
1481 | 1483 | | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
| 1484 | + | |
| 1485 | + | |
1486 | 1486 | | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1491 | 1492 | | |
1492 | 1493 | | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1496 | 1502 | | |
1497 | | - | |
1498 | | - | |
| 1503 | + | |
| 1504 | + | |
1499 | 1505 | | |
1500 | 1506 | | |
1501 | 1507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2953 | 2953 | | |
2954 | 2954 | | |
2955 | 2955 | | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
2956 | 2960 | | |
2957 | 2961 | | |
2958 | 2962 | | |
| |||
0 commit comments