Commit 3b00002
authored
Fix [override] error with no line number when argument node has no line number (python#18122)
Refs python#18115
When a parameter type in a method override is incompatible with the
parameter type in the supertype definition, mypy emits an error using
the `Argument` node as the context.
However, sometimes the the `Argument` node doesn't have a line number
set, causing the error message to have no associated line number. This
happens with the `__replace__` methods created in the dataclass plugin,
which have line numbers set on the `FuncDef` nodes, but no line numbers
set on the individual argument nodes.
This PR fixes the missing line number in the error by falling-back to
the FuncDef line number when a line number isn't set on the `Argument`
node.
(As an alternative fix, we could add line numbers to the `Argument`
nodes in the dataclass plugin, but that looks like a more complicated
change since multiple methods would be affected).1 parent eedee20 commit 3b00002
2 files changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2367 | 2367 | | |
2368 | 2368 | | |
2369 | 2369 | | |
| 2370 | + | |
2370 | 2371 | | |
2371 | | - | |
2372 | | - | |
2373 | | - | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
2374 | 2375 | | |
2375 | 2376 | | |
2376 | 2377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2523 | 2523 | | |
2524 | 2524 | | |
2525 | 2525 | | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
0 commit comments