mirror of https://github.com/astral-sh/ruff
red_knot: update diagnostic output snapshots
These should all be minor cosmetic changes. To summarize: * In many cases, `-` was replaced with `^` for primary annotations. This is because, previously, whether `-` or `^` was used depended on the severity. But in the new data model, it's based on whether the annotation is "primary" or not. We could of course change this in whatever way we want, but I think we should roll with this for now. * The "secondary messages" in the old API are rendered as sub-diagnostics. This in turn results in a small change in the output format, since previously, the secondary messages were represented as just another snippet. We use sub-diagnostics because that's the intended way to enforce relative ordering between messages within a diagnostic. * The "info:" prefix used in some annotation messages has been dropped. We could re-add this, but I think I like it better without this prefix. I believe those 3 cover all of the snapshot changes here.
This commit is contained in:
parent
6883c1dde7
commit
bd9eab059f
|
|
@ -219,7 +219,7 @@ fn configuration_rule_severity() -> anyhow::Result<()> {
|
|||
5 | x = a
|
||||
6 |
|
||||
7 | print(x) # possibly-unresolved-reference
|
||||
| - Name `x` used when possibly not defined
|
||||
| ^ Name `x` used when possibly not defined
|
||||
|
|
||||
|
||||
Found 2 diagnostics
|
||||
|
|
@ -244,7 +244,7 @@ fn configuration_rule_severity() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:2:5
|
||||
|
|
||||
2 | y = 4 / 0
|
||||
| ----- Cannot divide object of type `Literal[4]` by zero
|
||||
| ^^^^^ Cannot divide object of type `Literal[4]` by zero
|
||||
3 |
|
||||
4 | for a in range(0, y):
|
||||
|
|
||||
|
|
@ -306,7 +306,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
|
|||
7 | x = a
|
||||
8 |
|
||||
9 | print(x) # possibly-unresolved-reference
|
||||
| - Name `x` used when possibly not defined
|
||||
| ^ Name `x` used when possibly not defined
|
||||
|
|
||||
|
||||
Found 3 diagnostics
|
||||
|
|
@ -331,7 +331,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:2:8
|
||||
|
|
||||
2 | import does_not_exit
|
||||
| ------------- Cannot resolve import `does_not_exit`
|
||||
| ^^^^^^^^^^^^^ Cannot resolve import `does_not_exit`
|
||||
3 |
|
||||
4 | y = 4 / 0
|
||||
|
|
||||
|
|
@ -342,7 +342,7 @@ fn cli_rule_severity() -> anyhow::Result<()> {
|
|||
2 | import does_not_exit
|
||||
3 |
|
||||
4 | y = 4 / 0
|
||||
| ----- Cannot divide object of type `Literal[4]` by zero
|
||||
| ^^^^^ Cannot divide object of type `Literal[4]` by zero
|
||||
5 |
|
||||
6 | for a in range(0, y):
|
||||
|
|
||||
|
|
@ -393,7 +393,7 @@ fn cli_rule_severity_precedence() -> anyhow::Result<()> {
|
|||
5 | x = a
|
||||
6 |
|
||||
7 | print(x) # possibly-unresolved-reference
|
||||
| - Name `x` used when possibly not defined
|
||||
| ^ Name `x` used when possibly not defined
|
||||
|
|
||||
|
||||
Found 2 diagnostics
|
||||
|
|
@ -419,7 +419,7 @@ fn cli_rule_severity_precedence() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:2:5
|
||||
|
|
||||
2 | y = 4 / 0
|
||||
| ----- Cannot divide object of type `Literal[4]` by zero
|
||||
| ^^^^^ Cannot divide object of type `Literal[4]` by zero
|
||||
3 |
|
||||
4 | for a in range(0, y):
|
||||
|
|
||||
|
|
@ -456,7 +456,7 @@ fn configuration_unknown_rules() -> anyhow::Result<()> {
|
|||
|
|
||||
2 | [tool.knot.rules]
|
||||
3 | division-by-zer = "warn" # incorrect rule name
|
||||
| --------------- Unknown lint rule `division-by-zer`
|
||||
| ^^^^^^^^^^^^^^^ Unknown lint rule `division-by-zer`
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -498,7 +498,7 @@ fn exit_code_only_warnings() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:1:7
|
||||
|
|
||||
1 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -528,7 +528,7 @@ fn exit_code_only_info() -> anyhow::Result<()> {
|
|||
|
|
||||
2 | from typing_extensions import reveal_type
|
||||
3 | reveal_type(1)
|
||||
| -------------- info: Revealed type is `Literal[1]`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Literal[1]`
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -558,7 +558,7 @@ fn exit_code_only_info_and_error_on_warning_is_true() -> anyhow::Result<()> {
|
|||
|
|
||||
2 | from typing_extensions import reveal_type
|
||||
3 | reveal_type(1)
|
||||
| -------------- info: Revealed type is `Literal[1]`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Literal[1]`
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -581,7 +581,7 @@ fn exit_code_no_errors_but_error_on_warning_is_true() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:1:7
|
||||
|
|
||||
1 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -613,7 +613,7 @@ fn exit_code_no_errors_but_error_on_warning_is_enabled_in_configuration() -> any
|
|||
--> <temp_dir>/test.py:1:7
|
||||
|
|
||||
1 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
|
|
||||
|
||||
Found 1 diagnostic
|
||||
|
|
@ -642,7 +642,7 @@ fn exit_code_both_warnings_and_errors() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:2:7
|
||||
|
|
||||
2 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
3 | print(4[1]) # [non-subscriptable]
|
||||
|
|
||||
|
||||
|
|
@ -680,7 +680,7 @@ fn exit_code_both_warnings_and_errors_and_error_on_warning_is_true() -> anyhow::
|
|||
--> <temp_dir>/test.py:2:7
|
||||
|
|
||||
2 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
3 | print(4[1]) # [non-subscriptable]
|
||||
|
|
||||
|
||||
|
|
@ -718,7 +718,7 @@ fn exit_code_exit_zero_is_true() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/test.py:2:7
|
||||
|
|
||||
2 | print(x) # [unresolved-reference]
|
||||
| - Name `x` used when not defined
|
||||
| ^ Name `x` used when not defined
|
||||
3 | print(4[1]) # [non-subscriptable]
|
||||
|
|
||||
|
||||
|
|
@ -778,7 +778,7 @@ fn user_configuration() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/project/main.py:2:5
|
||||
|
|
||||
2 | y = 4 / 0
|
||||
| ----- Cannot divide object of type `Literal[4]` by zero
|
||||
| ^^^^^ Cannot divide object of type `Literal[4]` by zero
|
||||
3 |
|
||||
4 | for a in range(0, y):
|
||||
|
|
||||
|
|
@ -789,7 +789,7 @@ fn user_configuration() -> anyhow::Result<()> {
|
|||
5 | x = a
|
||||
6 |
|
||||
7 | print(x)
|
||||
| - Name `x` used when possibly not defined
|
||||
| ^ Name `x` used when possibly not defined
|
||||
|
|
||||
|
||||
Found 2 diagnostics
|
||||
|
|
@ -820,7 +820,7 @@ fn user_configuration() -> anyhow::Result<()> {
|
|||
--> <temp_dir>/project/main.py:2:5
|
||||
|
|
||||
2 | y = 4 / 0
|
||||
| ----- Cannot divide object of type `Literal[4]` by zero
|
||||
| ^^^^^ Cannot divide object of type `Literal[4]` by zero
|
||||
3 |
|
||||
4 | for a in range(0, y):
|
||||
|
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ warning: lint:possibly-unbound-attribute
|
|||
4 | attr: int = 0
|
||||
5 |
|
||||
6 | C.attr = 1 # error: [possibly-unbound-attribute]
|
||||
| ------ Attribute `attr` on type `Literal[C]` is possibly unbound
|
||||
| ^^^^^^ Attribute `attr` on type `Literal[C]` is possibly unbound
|
||||
7 |
|
||||
8 | instance = C()
|
||||
|
|
||||
|
|
@ -45,7 +45,7 @@ warning: lint:possibly-unbound-attribute
|
|||
|
|
||||
8 | instance = C()
|
||||
9 | instance.attr = 1 # error: [possibly-unbound-attribute]
|
||||
| ------------- Attribute `attr` on type `C` is possibly unbound
|
||||
| ^^^^^^^^^^^^^ Attribute `attr` on type `C` is possibly unbound
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ info: revealed-type
|
|||
9 | # error: [not-iterable]
|
||||
10 | for x in Iterable():
|
||||
11 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ info: revealed-type
|
|||
6 | # error: [not-iterable]
|
||||
7 | for x in Bad():
|
||||
8 | reveal_type(x) # revealed: Unknown
|
||||
| -------------- info: Revealed type is `Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ info: revealed-type
|
|||
22 | for x in Iterable1():
|
||||
23 | # TODO... `int` might be ideal here?
|
||||
24 | reveal_type(x) # revealed: int | Unknown
|
||||
| -------------- info: Revealed type is `int | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | Unknown`
|
||||
25 |
|
||||
26 | # error: [not-iterable]
|
||||
|
|
||||
|
|
@ -92,7 +92,7 @@ info: revealed-type
|
|||
27 | for y in Iterable2():
|
||||
28 | # TODO... `int` might be ideal here?
|
||||
29 | reveal_type(y) # revealed: int | Unknown
|
||||
| -------------- info: Revealed type is `int | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ info: revealed-type
|
|||
20 | for x in Iterable1():
|
||||
21 | # TODO: `str` might be better
|
||||
22 | reveal_type(x) # revealed: str | Unknown
|
||||
| -------------- info: Revealed type is `str | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `str | Unknown`
|
||||
23 |
|
||||
24 | # error: [not-iterable]
|
||||
|
|
||||
|
|
@ -88,7 +88,7 @@ info: revealed-type
|
|||
24 | # error: [not-iterable]
|
||||
25 | for y in Iterable2():
|
||||
26 | reveal_type(y) # revealed: str | int
|
||||
| -------------- info: Revealed type is `str | int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `str | int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ info: revealed-type
|
|||
16 | # error: [not-iterable]
|
||||
17 | for x in Iterable1():
|
||||
18 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
19 |
|
||||
20 | class Iterable2:
|
||||
|
|
||||
|
|
@ -92,7 +92,7 @@ info: revealed-type
|
|||
28 | for x in Iterable2():
|
||||
29 | # TODO: `int` would probably be better here:
|
||||
30 | reveal_type(x) # revealed: int | Unknown
|
||||
| -------------- info: Revealed type is `int | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ info: revealed-type
|
|||
27 | # error: [not-iterable]
|
||||
28 | for x in Iterable1():
|
||||
29 | reveal_type(x) # revealed: int | str
|
||||
| -------------- info: Revealed type is `int | str`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | str`
|
||||
30 |
|
||||
31 | # error: [not-iterable]
|
||||
|
|
||||
|
|
@ -96,7 +96,7 @@ info: revealed-type
|
|||
32 | for y in Iterable2():
|
||||
33 | # TODO: `int` would probably be better here:
|
||||
34 | reveal_type(y) # revealed: int | Unknown
|
||||
| -------------- info: Revealed type is `int | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ info: revealed-type
|
|||
17 | # error: [not-iterable]
|
||||
18 | for x in Iterable():
|
||||
19 | reveal_type(x) # revealed: int | bytes
|
||||
| -------------- info: Revealed type is `int | bytes`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | bytes`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ info: revealed-type
|
|||
31 | for x in Iterable1():
|
||||
32 | # TODO: `bytes | str` might be better
|
||||
33 | reveal_type(x) # revealed: bytes | str | Unknown
|
||||
| -------------- info: Revealed type is `bytes | str | Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `bytes | str | Unknown`
|
||||
34 |
|
||||
35 | # error: [not-iterable]
|
||||
|
|
||||
|
|
@ -99,7 +99,7 @@ info: revealed-type
|
|||
35 | # error: [not-iterable]
|
||||
36 | for y in Iterable2():
|
||||
37 | reveal_type(y) # revealed: bytes | str | int
|
||||
| -------------- info: Revealed type is `bytes | str | int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `bytes | str | int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ info: revealed-type
|
|||
16 | # error: [not-iterable]
|
||||
17 | for x in Iterable():
|
||||
18 | reveal_type(x) # revealed: int | bytes
|
||||
| -------------- info: Revealed type is `int | bytes`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int | bytes`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ info: revealed-type
|
|||
17 | # error: [not-iterable]
|
||||
18 | for x in Test() if flag else Test2():
|
||||
19 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ info: revealed-type
|
|||
12 | # error: [not-iterable]
|
||||
13 | for x in Test() if flag else 42:
|
||||
14 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ warning: lint:possibly-unresolved-reference
|
|||
14 | # revealed: Unknown
|
||||
15 | # error: [possibly-unresolved-reference]
|
||||
16 | reveal_type(x)
|
||||
| - Name `x` used when possibly not defined
|
||||
| ^ Name `x` used when possibly not defined
|
||||
|
|
||||
|
||||
```
|
||||
|
|
@ -63,7 +63,7 @@ info: revealed-type
|
|||
14 | # revealed: Unknown
|
||||
15 | # error: [possibly-unresolved-reference]
|
||||
16 | reveal_type(x)
|
||||
| -------------- info: Revealed type is `Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ info: revealed-type
|
|||
7 | # error: [not-iterable]
|
||||
8 | for x in Bad():
|
||||
9 | reveal_type(x) # revealed: Unknown
|
||||
| -------------- info: Revealed type is `Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ info: revealed-type
|
|||
11 | # error: [not-iterable]
|
||||
12 | for x in Iterable():
|
||||
13 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ info: revealed-type
|
|||
18 | # error: [not-iterable]
|
||||
19 | for x in Iterable1():
|
||||
20 | reveal_type(x) # revealed: int
|
||||
| -------------- info: Revealed type is `int`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `int`
|
||||
21 |
|
||||
22 | # error: [not-iterable]
|
||||
|
|
||||
|
|
@ -85,7 +85,7 @@ info: revealed-type
|
|||
22 | # error: [not-iterable]
|
||||
23 | for y in Iterable2():
|
||||
24 | reveal_type(y) # revealed: Unknown
|
||||
| -------------- info: Revealed type is `Unknown`
|
||||
| ^^^^^^^^^^^^^^ Revealed type is `Unknown`
|
||||
|
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo("hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 1 (`x`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:9
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:9
|
||||
|
|
||||
1 | def foo(x: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * x
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,12 @@ error: lint:invalid-argument-type
|
|||
6 | c.square("hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 2 (`x`) of bound method `square`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:2:22
|
||||
info
|
||||
--> /src/mdtest_snippet.py:2:22
|
||||
|
|
||||
1 | class C:
|
||||
2 | def square(self, x: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
3 | return x * x
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,11 @@ error: lint:invalid-argument-type
|
|||
3 | package.foo("hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 1 (`x`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/package.py:1:9
|
||||
info
|
||||
--> /src/package.py:1:9
|
||||
|
|
||||
1 | def foo(x: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * x
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,13 @@ error: lint:invalid-argument-type
|
|||
3 |
|
||||
4 | def foo(x: int) -> int:
|
||||
|
|
||||
::: /src/mdtest_snippet.py:4:9
|
||||
info
|
||||
--> /src/mdtest_snippet.py:4:9
|
||||
|
|
||||
2 | foo("hello") # error: [invalid-argument-type]
|
||||
3 |
|
||||
4 | def foo(x: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
5 | return x * x
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, "hello", 3) # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 2 (`y`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:17
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:17
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ error: lint:invalid-argument-type
|
|||
8 | foo(1, "hello", 3) # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 2 (`y`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:3:5
|
||||
info
|
||||
--> /src/mdtest_snippet.py:3:5
|
||||
|
|
||||
1 | def foo(
|
||||
2 | x: int,
|
||||
3 | y: int,
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
4 | z: int,
|
||||
5 | ) -> int:
|
||||
|
|
||||
|
|
|
|||
|
|
@ -32,10 +32,11 @@ error: lint:invalid-argument-type
|
|||
7 | foo("a", "b", "c")
|
||||
| ^^^ Object of type `Literal["a"]` cannot be assigned to parameter 1 (`x`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:9
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:9
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
@ -50,10 +51,11 @@ error: lint:invalid-argument-type
|
|||
7 | foo("a", "b", "c")
|
||||
| ^^^ Object of type `Literal["b"]` cannot be assigned to parameter 2 (`y`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:17
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:17
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
@ -68,10 +70,11 @@ error: lint:invalid-argument-type
|
|||
7 | foo("a", "b", "c")
|
||||
| ^^^ Object of type `Literal["c"]` cannot be assigned to parameter 3 (`z`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:25
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:25
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -21,19 +21,20 @@ mdtest path: crates/red_knot_python_semantic/resources/mdtest/diagnostics/invali
|
|||
|
||||
```
|
||||
error: lint:invalid-argument-type
|
||||
--> /src/mdtest_snippet.py:3:12
|
||||
|
|
||||
1 | import json
|
||||
2 |
|
||||
3 | json.loads(5) # error: [invalid-argument-type]
|
||||
| ^ Object of type `Literal[5]` cannot be assigned to parameter 1 (`s`) of function `loads`; expected type `str | bytes | bytearray`
|
||||
|
|
||||
::: vendored://stdlib/json/__init__.pyi:40:5
|
||||
--> /src/mdtest_snippet.py:3:12
|
||||
|
|
||||
1 | import json
|
||||
2 |
|
||||
3 | json.loads(5) # error: [invalid-argument-type]
|
||||
| ^ Object of type `Literal[5]` cannot be assigned to parameter 1 (`s`) of function `loads`; expected type `str | bytes | bytearray`
|
||||
|
|
||||
info
|
||||
--> stdlib/json/__init__.pyi:40:5
|
||||
|
|
||||
38 | ) -> None: ...
|
||||
39 | def loads(
|
||||
40 | s: str | bytes | bytearray,
|
||||
| -------------------------- info: parameter declared in function definition here
|
||||
| -------------------------- parameter declared in function definition here
|
||||
41 | *,
|
||||
42 | cls: type[JSONDecoder] | None = None,
|
||||
|
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, 2, z="hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter `z` of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:28
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:28
|
||||
|
|
||||
1 | def foo(x: int, y: int, *, z: int = 0) -> int:
|
||||
| ---------- info: parameter declared in function definition here
|
||||
| ---------- parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, 2, z="hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter `z` of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:31
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:31
|
||||
|
|
||||
1 | def foo(x: int, /, y: int, *, z: int = 0) -> int:
|
||||
| ---------- info: parameter declared in function definition here
|
||||
| ---------- parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, 2, "hello") # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 3 (`z`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:25
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:25
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int = 0) -> int:
|
||||
| ---------- info: parameter declared in function definition here
|
||||
| ---------- parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, "hello", 3) # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter 2 (`y`) of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:17
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:17
|
||||
|
|
||||
1 | def foo(x: int, y: int, z: int, /) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
2 | return x * y * z
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,12 @@ error: lint:invalid-argument-type
|
|||
6 | c("wrong") # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["wrong"]` cannot be assigned to parameter 2 (`x`) of bound method `__call__`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:2:24
|
||||
info
|
||||
--> /src/mdtest_snippet.py:2:24
|
||||
|
|
||||
1 | class C:
|
||||
2 | def __call__(self, x: int) -> int:
|
||||
| ------ info: parameter declared in function definition here
|
||||
| ------ parameter declared in function definition here
|
||||
3 | return 1
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(1, 2, 3, "hello", 5) # error: [invalid-argument-type]
|
||||
| ^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter `*numbers` of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:9
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:9
|
||||
|
|
||||
1 | def foo(*numbers: int) -> int:
|
||||
| ------------- info: parameter declared in function definition here
|
||||
| ------------- parameter declared in function definition here
|
||||
2 | return len(numbers)
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ error: lint:invalid-argument-type
|
|||
4 | foo(a=1, b=2, c=3, d="hello", e=5) # error: [invalid-argument-type]
|
||||
| ^^^^^^^^^ Object of type `Literal["hello"]` cannot be assigned to parameter `**numbers` of function `foo`; expected type `int`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:9
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:9
|
||||
|
|
||||
1 | def foo(**numbers: int) -> int:
|
||||
| -------------- info: parameter declared in function definition here
|
||||
| -------------- parameter declared in function definition here
|
||||
2 | return len(numbers)
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,11 @@ error: lint:invalid-return-type
|
|||
7 |
|
||||
8 | def f(cond: bool) -> str:
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:22
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:22
|
||||
|
|
||||
1 | def f(cond: bool) -> str:
|
||||
| --- info: Return type is declared here as `str`
|
||||
| --- Return type is declared here as `str`
|
||||
2 | if cond:
|
||||
3 | return "a"
|
||||
|
|
||||
|
|
@ -62,12 +63,13 @@ error: lint:invalid-return-type
|
|||
12 | else:
|
||||
13 | # error: [invalid-return-type]
|
||||
|
|
||||
::: /src/mdtest_snippet.py:8:22
|
||||
info
|
||||
--> /src/mdtest_snippet.py:8:22
|
||||
|
|
||||
6 | return 1
|
||||
7 |
|
||||
8 | def f(cond: bool) -> str:
|
||||
| --- info: Return type is declared here as `str`
|
||||
| --- Return type is declared here as `str`
|
||||
9 | if cond:
|
||||
10 | # error: [invalid-return-type]
|
||||
|
|
||||
|
|
@ -83,12 +85,13 @@ error: lint:invalid-return-type
|
|||
14 | return 2
|
||||
| ^ Object of type `Literal[2]` is not assignable to return type `str`
|
||||
|
|
||||
::: /src/mdtest_snippet.py:8:22
|
||||
info
|
||||
--> /src/mdtest_snippet.py:8:22
|
||||
|
|
||||
6 | return 1
|
||||
7 |
|
||||
8 | def f(cond: bool) -> str:
|
||||
| --- info: Return type is declared here as `str`
|
||||
| --- Return type is declared here as `str`
|
||||
9 | if cond:
|
||||
10 | # error: [invalid-return-type]
|
||||
|
|
||||
|
|
|
|||
|
|
@ -50,10 +50,11 @@ error: lint:invalid-return-type
|
|||
5 |
|
||||
6 | # error: [invalid-return-type]
|
||||
|
|
||||
::: /src/mdtest_snippet.py:1:12
|
||||
info
|
||||
--> /src/mdtest_snippet.py:1:12
|
||||
|
|
||||
1 | def f() -> None:
|
||||
| ---- info: Return type is declared here as `None`
|
||||
| ---- Return type is declared here as `None`
|
||||
2 | if False:
|
||||
3 | # error: [invalid-return-type]
|
||||
|
|
||||
|
|
|
|||
|
|
@ -57,12 +57,13 @@ error: lint:invalid-return-type
|
|||
8 |
|
||||
9 | def f() -> int:
|
||||
|
|
||||
::: /src/mdtest_snippet.py:5:12
|
||||
info
|
||||
--> /src/mdtest_snippet.py:5:12
|
||||
|
|
||||
3 | 1
|
||||
4 |
|
||||
5 | def f() -> str:
|
||||
| --- info: Return type is declared here as `str`
|
||||
| --- Return type is declared here as `str`
|
||||
6 | # error: [invalid-return-type]
|
||||
7 | return 1
|
||||
|
|
||||
|
|
@ -80,12 +81,13 @@ error: lint:invalid-return-type
|
|||
12 |
|
||||
13 | from typing import TypeVar
|
||||
|
|
||||
::: /src/mdtest_snippet.py:9:12
|
||||
info
|
||||
--> /src/mdtest_snippet.py:9:12
|
||||
|
|
||||
7 | return 1
|
||||
8 |
|
||||
9 | def f() -> int:
|
||||
| --- info: Return type is declared here as `int`
|
||||
| --- Return type is declared here as `int`
|
||||
10 | # error: [invalid-return-type]
|
||||
11 | return
|
||||
|
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ error: lint:invalid-return-type
|
|||
4 |
|
||||
5 | # error: [invalid-return-type]
|
||||
|
|
||||
::: /src/mdtest_snippet.pyi:1:12
|
||||
info
|
||||
--> /src/mdtest_snippet.pyi:1:12
|
||||
|
|
||||
1 | def f() -> int:
|
||||
| --- info: Return type is declared here as `int`
|
||||
| --- Return type is declared here as `int`
|
||||
2 | # error: [invalid-return-type]
|
||||
3 | return ...
|
||||
|
|
||||
|
|
|
|||
Loading…
Reference in New Issue