red_knot_python_semantic: migrate INVALID_ASSIGNMENT for shadowing

We mostly keep things the same here, but the message has been moved from
the annotation to the diagnostic's top-line message. I think this is
perhaps a little worse, but some bigger improvements could be made here.
Indeed, we could perhaps even add a "fix" here.
This commit is contained in:
Andrew Gallant
2025-04-16 10:29:41 -04:00
committed by Andrew Gallant
parent 890ba725d9
commit 6dc2d29966
9 changed files with 109 additions and 17 deletions

View File

@@ -0,0 +1,19 @@
# Shadowing
<!-- snapshot-diagnostics -->
## Implicit class shadowing
```py
class C: ...
C = 1 # error: [invalid-assignment]
```
## Implicit function shadowing
```py
def f(): ...
f = 1 # error: [invalid-assignment]
```