Commit f0c1fdc
committed
fix: prevent false unreachable error when comparing generic callables
When comparing a generic Callable parameter with a generic function
using ==, mypy incorrectly concluded the types could never overlap
and marked the if-body as unreachable.
Fix by extending shallow_erase_type_for_equality to handle CallableType
and using erased current_type in the equality overlap checks.
Fixes #21182
Signed-off-by: bahtya <bahtyar153@qq.com>1 parent bb05513 commit f0c1fdc
2 files changed
+26
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8478 | 8478 | | |
8479 | 8479 | | |
8480 | 8480 | | |
| 8481 | + | |
| 8482 | + | |
| 8483 | + | |
8481 | 8484 | | |
8482 | | - | |
| 8485 | + | |
8483 | 8486 | | |
8484 | 8487 | | |
8485 | 8488 | | |
8486 | 8489 | | |
8487 | | - | |
| 8490 | + | |
8488 | 8491 | | |
8489 | 8492 | | |
8490 | 8493 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
294 | 300 | | |
| |||
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
301 | 321 | | |
0 commit comments