Commit a0307b5
authored
Extend special case for context-based typevar inference to typevar unions in return position (#18976)
* Fixes #17221.
* Fixes #17654.
* Fixes #17553.
* Fixes #17536.
* Fixes #16659.
* Fixes #16267.
* Fixes #15755.
* Fixes #15150.
* Fixes #14664.
* Incidentally improves error message in #12156.
* Fixes #12092.
* Fixes #11985.
* Improves #11455 (but the problem with union `TypeVar | SomeFixedType`
reported in comments there remains).
* Fixes #10426.
When using context, we can perform some overly optimistic inference when
return type is `T1 | T2`. This breaks in important case of
`builtins.min` when `default` and `key` are passed, essentially making
them always incompatible. This is not the most principled approach, but
let's see the primer results.
This resolves quite a few issues (some of them duplicates, but some -
substantially different), `min` problem was a very popular one... Diff
run: sterliakov/mypy-issues#301 parent 9e45dad commit a0307b5
File tree
2 files changed
+21
-1
lines changed- mypy
- test-data/unit
2 files changed
+21
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2013 | 2013 | | |
2014 | 2014 | | |
2015 | 2015 | | |
2016 | | - | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
2017 | 2022 | | |
2018 | 2023 | | |
2019 | 2024 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1495 | 1495 | | |
1496 | 1496 | | |
1497 | 1497 | | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
0 commit comments