mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
red_knot_python_semantic: migrate types/infer
to new diagnostic model
I gave up trying to do this one lint at a time and just (mostly) mechanically translated this entire file in one go. Generally the messages stay the same (with most moving from an annotation message to the diagnostic's main message). I added a couple of `info` sub-diagnostics where it seemed to be the obvious intent.
This commit is contained in:
parent
b8b624d890
commit
27a377f077
13 changed files with 485 additions and 461 deletions
|
@ -40,13 +40,13 @@ error: lint:invalid-assignment: Object of type `Literal["wrong"]` is not assigna
|
|||
```
|
||||
|
||||
```
|
||||
error: lint:invalid-attribute-access
|
||||
error: lint:invalid-attribute-access: Cannot assign to instance attribute `attr` from the class object `Literal[C]`
|
||||
--> /src/mdtest_snippet.py:9:1
|
||||
|
|
||||
7 | instance.attr = "wrong" # error: [invalid-assignment]
|
||||
8 |
|
||||
9 | C.attr = 1 # error: [invalid-attribute-access]
|
||||
| ^^^^^^ Cannot assign to instance attribute `attr` from the class object `Literal[C]`
|
||||
| ^^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -23,13 +23,13 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/attrib
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-attribute
|
||||
error: lint:unresolved-attribute: Unresolved attribute `non_existent` on type `Literal[C]`.
|
||||
--> /src/mdtest_snippet.py:3:1
|
||||
|
|
||||
1 | class C: ...
|
||||
2 |
|
||||
3 | C.non_existent = 1 # error: [unresolved-attribute]
|
||||
| ^^^^^^^^^^^^^^ Unresolved attribute `non_existent` on type `Literal[C]`.
|
||||
| ^^^^^^^^^^^^^^
|
||||
4 |
|
||||
5 | instance = C()
|
||||
|
|
||||
|
@ -37,12 +37,12 @@ error: lint:unresolved-attribute
|
|||
```
|
||||
|
||||
```
|
||||
error: lint:unresolved-attribute
|
||||
error: lint:unresolved-attribute: Unresolved attribute `non_existent` on type `C`.
|
||||
--> /src/mdtest_snippet.py:6:1
|
||||
|
|
||||
5 | instance = C()
|
||||
6 | instance.non_existent = 1 # error: [unresolved-attribute]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ Unresolved attribute `non_existent` on type `C`.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -40,12 +40,12 @@ error: lint:invalid-assignment: Object of type `Literal["wrong"]` is not assigna
|
|||
```
|
||||
|
||||
```
|
||||
error: lint:invalid-attribute-access
|
||||
error: lint:invalid-attribute-access: Cannot assign to ClassVar `attr` from an instance of type `C`
|
||||
--> /src/mdtest_snippet.py:10:1
|
||||
|
|
||||
9 | instance = C()
|
||||
10 | instance.attr = 1 # error: [invalid-attribute-access]
|
||||
| ^^^^^^^^^^^^^ Cannot assign to ClassVar `attr` from an instance of type `C`
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -18,11 +18,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/import/basic.md
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `zqzqzqzqzqzqzq`
|
||||
--> /src/mdtest_snippet.py:1:8
|
||||
|
|
||||
1 | import zqzqzqzqzqzqzq # error: [unresolved-import] "Cannot resolve import `zqzqzqzqzqzqzq`"
|
||||
| ^^^^^^^^^^^^^^ Cannot resolve import `zqzqzqzqzqzqzq`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -27,12 +27,12 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/import/basic.md
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `a.foo`
|
||||
--> /src/mdtest_snippet.py:2:8
|
||||
|
|
||||
1 | # Topmost component resolvable, submodule not resolvable:
|
||||
2 | import a.foo # error: [unresolved-import] "Cannot resolve import `a.foo`"
|
||||
| ^^^^^ Cannot resolve import `a.foo`
|
||||
| ^^^^^
|
||||
3 |
|
||||
4 | # Topmost component unresolvable:
|
||||
|
|
||||
|
@ -40,12 +40,12 @@ error: lint:unresolved-import
|
|||
```
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `b.foo`
|
||||
--> /src/mdtest_snippet.py:5:8
|
||||
|
|
||||
4 | # Topmost component unresolvable:
|
||||
5 | import b.foo # error: [unresolved-import] "Cannot resolve import `b.foo`"
|
||||
| ^^^^^ Cannot resolve import `b.foo`
|
||||
| ^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -20,11 +20,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `does_not_exist`
|
||||
--> /src/mdtest_snippet.py:1:8
|
||||
|
|
||||
1 | import does_not_exist # error: [unresolved-import]
|
||||
| ^^^^^^^^^^^^^^ Cannot resolve import `does_not_exist`
|
||||
| ^^^^^^^^^^^^^^
|
||||
2 |
|
||||
3 | x = does_not_exist.foo
|
||||
|
|
||||
|
|
|
@ -25,11 +25,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Module `a` has no member `does_not_exist`
|
||||
--> /src/mdtest_snippet.py:1:28
|
||||
|
|
||||
1 | from a import does_exist1, does_not_exist, does_exist2 # error: [unresolved-import]
|
||||
| ^^^^^^^^^^^^^^ Module `a` has no member `does_not_exist`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
@ -20,11 +20,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `.does_not_exist`
|
||||
--> /src/mdtest_snippet.py:1:7
|
||||
|
|
||||
1 | from .does_not_exist import add # error: [unresolved-import]
|
||||
| ^^^^^^^^^^^^^^ Cannot resolve import `.does_not_exist`
|
||||
| ^^^^^^^^^^^^^^
|
||||
2 |
|
||||
3 | stat = add(10, 15)
|
||||
|
|
||||
|
|
|
@ -20,11 +20,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `.does_not_exist.foo.bar`
|
||||
--> /src/mdtest_snippet.py:1:7
|
||||
|
|
||||
1 | from .does_not_exist.foo.bar import add # error: [unresolved-import]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ Cannot resolve import `.does_not_exist.foo.bar`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
2 |
|
||||
3 | stat = add(10, 15)
|
||||
|
|
||||
|
|
|
@ -20,11 +20,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `does_not_exist`
|
||||
--> /src/mdtest_snippet.py:1:6
|
||||
|
|
||||
1 | from does_not_exist import add # error: [unresolved-import]
|
||||
| ^^^^^^^^^^^^^^ Cannot resolve import `does_not_exist`
|
||||
| ^^^^^^^^^^^^^^
|
||||
2 |
|
||||
3 | stat = add(10, 15)
|
||||
|
|
||||
|
|
|
@ -32,11 +32,11 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/unreso
|
|||
# Diagnostics
|
||||
|
||||
```
|
||||
error: lint:unresolved-import
|
||||
error: lint:unresolved-import: Cannot resolve import `....foo`
|
||||
--> /src/package/subpackage/subsubpackage/__init__.py:1:10
|
||||
|
|
||||
1 | from ....foo import add # error: [unresolved-import]
|
||||
| ^^^ Cannot resolve import `....foo`
|
||||
| ^^^
|
||||
2 |
|
||||
3 | stat = add(10, 15)
|
||||
|
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue