[ty] Cover full range of annotated assignments (#20261)

## Summary

An annotated assignment `name: annotation` without a right-hand side was
previously not covered by the range returned from
`DefinitionKind::full_range`, because we did expand the range to include
the right-hand side (if there was one), but failed to include the
annotation.

## Test Plan

Updated snapshot tests
This commit is contained in:
David Peter
2025-09-05 10:12:40 +02:00
committed by GitHub
parent 7509d376eb
commit 9e45bfa9fd
2 changed files with 12 additions and 11 deletions

View File

@@ -47,7 +47,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
| --------------------- Earlier field `altitude` defined here with a default value
5 | # error: [invalid-named-tuple] "NamedTuple field without default value cannot follow field(s) with default value(s): Field `latitud…
6 | latitude: float
| ^^^^^^^^ Field `latitude` defined here without a default value
| ^^^^^^^^^^^^^^^ Field `latitude` defined here without a default value
7 | # error: [invalid-named-tuple] "NamedTuple field without default value cannot follow field(s) with default value(s): Field `longitu…
8 | longitude: float
|
@@ -66,7 +66,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
6 | latitude: float
7 | # error: [invalid-named-tuple] "NamedTuple field without default value cannot follow field(s) with default value(s): Field `longit…
8 | longitude: float
| ^^^^^^^^^ Field `longitude` defined here without a default value
| ^^^^^^^^^^^^^^^^ Field `longitude` defined here without a default value
9 |
10 | class StrangeLocation(NamedTuple):
|
@@ -83,7 +83,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
14 | altitude: float = 0.0
| --------------------- Earlier field `altitude` defined here with a default value
15 | latitude: float # error: [invalid-named-tuple]
| ^^^^^^^^ Field `latitude` defined here without a default value
| ^^^^^^^^^^^^^^^ Field `latitude` defined here without a default value
16 | longitude: float # error: [invalid-named-tuple]
|
info: rule `invalid-named-tuple` is enabled by default
@@ -100,7 +100,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
| --------------------- Earlier field `altitude` defined here with a default value
15 | latitude: float # error: [invalid-named-tuple]
16 | longitude: float # error: [invalid-named-tuple]
| ^^^^^^^^^ Field `longitude` defined here without a default value
| ^^^^^^^^^^^^^^^^ Field `longitude` defined here without a default value
17 |
18 | class VeryStrangeLocation(NamedTuple):
|
@@ -115,7 +115,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
18 | class VeryStrangeLocation(NamedTuple):
19 | altitude: float = 0.0
20 | latitude: float # error: [invalid-named-tuple]
| ^^^^^^^^ Field `latitude` defined here without a default value
| ^^^^^^^^^^^^^^^ Field `latitude` defined here without a default value
21 | longitude: float # error: [invalid-named-tuple]
22 | altitude: float = 0.0
|
@@ -131,7 +131,7 @@ error[invalid-named-tuple]: NamedTuple field without default value cannot follow
19 | altitude: float = 0.0
20 | latitude: float # error: [invalid-named-tuple]
21 | longitude: float # error: [invalid-named-tuple]
| ^^^^^^^^^ Field `longitude` defined here without a default value
| ^^^^^^^^^^^^^^^^ Field `longitude` defined here without a default value
22 | altitude: float = 0.0
|
info: Earlier field `altitude` was defined with a default value