[red-knot] Assignability of class literals to Callables (#17704)

## Summary

Subtyping was already modeled, but assignability also needs an explicit
branch. Removes 921 ecosystem false positives.

## Test Plan

New Markdown tests.
This commit is contained in:
David Peter
2025-04-29 15:04:22 +02:00
committed by GitHub
parent ca4fdf452d
commit 79f8473e51
2 changed files with 19 additions and 0 deletions

View File

@@ -529,6 +529,18 @@ c: Callable[[Any], str] = A().f
c: Callable[[Any], str] = A().g
```
### Class literal types
```py
from typing import Any, Callable
c: Callable[[str], Any] = str
c: Callable[[str], Any] = int
# error: [invalid-assignment]
c: Callable[[str], Any] = object
```
### Overloads
`overloaded.pyi`: