Commit 53cfee2
committed
fix: don't suggest Foo[...] when Foo(arg=...) is used
When a function call with keyword arguments appears in a type
annotation (e.g. `Foo(sort=True)`), mypy was suggesting to use
`Foo[...]` instead. This suggestion is misleading because
`Foo[sort=True]` is a syntax error -- the user likely intended a
function call, not a type parameterization.
Now, when keyword arguments are present, mypy shows "Cannot use a
function call in a type annotation" instead. The `Foo[...]` suggestion
is preserved for calls with only positional arguments (e.g. `Foo(int)`)
where the user likely meant `Foo[int]`.
Fixes #165061 parent a475a9a commit 53cfee2
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1958 | 1958 | | |
1959 | 1959 | | |
1960 | 1960 | | |
1961 | | - | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
1962 | 1965 | | |
1963 | 1966 | | |
1964 | 1967 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
210 | 221 | | |
211 | 222 | | |
212 | 223 | | |
| |||
0 commit comments