[ty] Sort collected diagnostics before snapshotting them in mdtest (#17926)
Some checks are pending
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run

This commit is contained in:
Alex Waygood 2025-05-07 18:23:22 +01:00 committed by GitHub
parent 51386b3c7a
commit 74fe7982ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 295 additions and 251 deletions

View file

@ -46,6 +46,18 @@ info: `lint:not-iterable` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:16:5
|
14 | # revealed: Unknown
15 | # error: [possibly-unresolved-reference]
16 | reveal_type(x)
| ^^^^^^^^^^^^^^ `Unknown`
|
```
```
warning: lint:possibly-unresolved-reference: Name `x` used when possibly not defined
--> src/mdtest_snippet.py:16:17
@ -58,15 +70,3 @@ warning: lint:possibly-unresolved-reference: Name `x` used when possibly not def
info: `lint:possibly-unresolved-reference` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:16:5
|
14 | # revealed: Unknown
15 | # error: [possibly-unresolved-reference]
16 | reveal_type(x)
| ^^^^^^^^^^^^^^ `Unknown`
|
```

View file

@ -55,6 +55,18 @@ info: revealed-type: Revealed type
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:12:1
|
10 | reveal_type(f(True)) # revealed: Literal[True]
11 | # error: [invalid-argument-type]
12 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```
```
error: lint:invalid-argument-type: Argument to this function is incorrect
--> src/mdtest_snippet.py:12:15
@ -77,15 +89,3 @@ info: Type variable defined here
info: `lint:invalid-argument-type` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:12:1
|
10 | reveal_type(f(True)) # revealed: Literal[True]
11 | # error: [invalid-argument-type]
12 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```

View file

@ -70,6 +70,18 @@ info: revealed-type: Revealed type
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:13:1
|
11 | reveal_type(f(None)) # revealed: None
12 | # error: [invalid-argument-type]
13 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```
```
error: lint:invalid-argument-type: Argument to this function is incorrect
--> src/mdtest_snippet.py:13:15
@ -92,15 +104,3 @@ info: Type variable defined here
info: `lint:invalid-argument-type` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:13:1
|
11 | reveal_type(f(None)) # revealed: None
12 | # error: [invalid-argument-type]
13 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```

View file

@ -52,6 +52,18 @@ info: revealed-type: Revealed type
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:9:1
|
7 | reveal_type(f(True)) # revealed: Literal[True]
8 | # error: [invalid-argument-type]
9 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```
```
error: lint:invalid-argument-type: Argument to this function is incorrect
--> src/mdtest_snippet.py:9:15
@ -73,15 +85,3 @@ info: Type variable defined here
info: `lint:invalid-argument-type` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:9:1
|
7 | reveal_type(f(True)) # revealed: Literal[True]
8 | # error: [invalid-argument-type]
9 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```

View file

@ -67,6 +67,18 @@ info: revealed-type: Revealed type
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:10:1
|
8 | reveal_type(f(None)) # revealed: None
9 | # error: [invalid-argument-type]
10 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```
```
error: lint:invalid-argument-type: Argument to this function is incorrect
--> src/mdtest_snippet.py:10:15
@ -88,15 +100,3 @@ info: Type variable defined here
info: `lint:invalid-argument-type` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:10:1
|
8 | reveal_type(f(None)) # revealed: None
9 | # error: [invalid-argument-type]
10 | reveal_type(f("string")) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
|
```

View file

@ -99,6 +99,33 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/mro.md
# Diagnostics
```
error: lint:duplicate-base: Duplicate base class `str`
--> src/mdtest_snippet.py:3:7
|
1 | from typing_extensions import reveal_type
2 |
3 | class Foo(str, str): ... # error: [duplicate-base] "Duplicate base class `str`"
| ^^^^^^^^^^^^^
4 |
5 | reveal_type(Foo.__mro__) # revealed: tuple[<class 'Foo'>, Unknown, <class 'object'>]
|
info: The definition of class `Foo` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:3:11
|
1 | from typing_extensions import reveal_type
2 |
3 | class Foo(str, str): ... # error: [duplicate-base] "Duplicate base class `str`"
| --- ^^^ Class `str` later repeated here
| |
| Class `str` first included in bases list here
4 |
5 | reveal_type(Foo.__mro__) # revealed: tuple[<class 'Foo'>, Unknown, <class 'object'>]
|
info: `lint:duplicate-base` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:5:1
@ -113,34 +140,6 @@ info: revealed-type: Revealed type
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:27:1
|
25 | # fmt: on
26 |
27 | reveal_type(Ham.__mro__) # revealed: tuple[<class 'Ham'>, Unknown, <class 'object'>]
| ^^^^^^^^^^^^^^^^^^^^^^^^ `tuple[<class 'Ham'>, Unknown, <class 'object'>]`
28 |
29 | class Mushrooms: ...
|
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:32:1
|
30 | class Omelette(Spam, Eggs, Mushrooms, Mushrooms): ... # error: [duplicate-base]
31 |
32 | reveal_type(Omelette.__mro__) # revealed: tuple[<class 'Omelette'>, Unknown, <class 'object'>]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `tuple[<class 'Omelette'>, Unknown, <class 'object'>]`
33 |
34 | # fmt: off
|
```
```
error: lint:duplicate-base: Duplicate base class `Spam`
--> src/mdtest_snippet.py:16:7
@ -217,63 +216,16 @@ info: `lint:duplicate-base` is enabled by default
```
```
error: lint:duplicate-base: Duplicate base class `A`
--> src/mdtest_snippet.py:76:7
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:27:1
|
75 | # error: [duplicate-base]
76 | class E(
| _______^
77 | | A,
78 | | A
79 | | ):
| |_^
80 | # error: [unused-ignore-comment]
81 | x: int # type: ignore[duplicate-base]
25 | # fmt: on
26 |
27 | reveal_type(Ham.__mro__) # revealed: tuple[<class 'Ham'>, Unknown, <class 'object'>]
| ^^^^^^^^^^^^^^^^^^^^^^^^ `tuple[<class 'Ham'>, Unknown, <class 'object'>]`
28 |
29 | class Mushrooms: ...
|
info: The definition of class `E` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:77:5
|
75 | # error: [duplicate-base]
76 | class E(
77 | A,
| - Class `A` first included in bases list here
78 | A
| ^ Class `A` later repeated here
79 | ):
80 | # error: [unused-ignore-comment]
|
info: `lint:duplicate-base` is enabled by default
```
```
error: lint:duplicate-base: Duplicate base class `A`
--> src/mdtest_snippet.py:69:7
|
68 | # error: [duplicate-base]
69 | class D(
| _______^
70 | | A,
71 | | # error: [unused-ignore-comment]
72 | | A, # type: ignore[duplicate-base]
73 | | ): ...
| |_^
74 |
75 | # error: [duplicate-base]
|
info: The definition of class `D` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:70:5
|
68 | # error: [duplicate-base]
69 | class D(
70 | A,
| - Class `A` first included in bases list here
71 | # error: [unused-ignore-comment]
72 | A, # type: ignore[duplicate-base]
| ^ Class `A` later repeated here
73 | ): ...
|
info: `lint:duplicate-base` is enabled by default
```
@ -302,6 +254,20 @@ info: `lint:duplicate-base` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:32:1
|
30 | class Omelette(Spam, Eggs, Mushrooms, Mushrooms): ... # error: [duplicate-base]
31 |
32 | reveal_type(Omelette.__mro__) # revealed: tuple[<class 'Omelette'>, Unknown, <class 'object'>]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `tuple[<class 'Omelette'>, Unknown, <class 'object'>]`
33 |
34 | # fmt: off
|
```
```
error: lint:duplicate-base: Duplicate base class `Eggs`
--> src/mdtest_snippet.py:37:7
@ -348,28 +314,32 @@ info: `lint:duplicate-base` is enabled by default
```
```
error: lint:duplicate-base: Duplicate base class `str`
--> src/mdtest_snippet.py:3:7
|
1 | from typing_extensions import reveal_type
2 |
3 | class Foo(str, str): ... # error: [duplicate-base] "Duplicate base class `str`"
| ^^^^^^^^^^^^^
4 |
5 | reveal_type(Foo.__mro__) # revealed: tuple[<class 'Foo'>, Unknown, <class 'object'>]
|
info: The definition of class `Foo` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:3:11
|
1 | from typing_extensions import reveal_type
2 |
3 | class Foo(str, str): ... # error: [duplicate-base] "Duplicate base class `str`"
| --- ^^^ Class `str` later repeated here
| |
| Class `str` first included in bases list here
4 |
5 | reveal_type(Foo.__mro__) # revealed: tuple[<class 'Foo'>, Unknown, <class 'object'>]
|
error: lint:duplicate-base: Duplicate base class `A`
--> src/mdtest_snippet.py:69:7
|
68 | # error: [duplicate-base]
69 | class D(
| _______^
70 | | A,
71 | | # error: [unused-ignore-comment]
72 | | A, # type: ignore[duplicate-base]
73 | | ): ...
| |_^
74 |
75 | # error: [duplicate-base]
|
info: The definition of class `D` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:70:5
|
68 | # error: [duplicate-base]
69 | class D(
70 | A,
| - Class `A` first included in bases list here
71 | # error: [unused-ignore-comment]
72 | A, # type: ignore[duplicate-base]
| ^ Class `A` later repeated here
73 | ): ...
|
info: `lint:duplicate-base` is enabled by default
```
@ -387,6 +357,36 @@ warning: lint:unused-ignore-comment
```
```
error: lint:duplicate-base: Duplicate base class `A`
--> src/mdtest_snippet.py:76:7
|
75 | # error: [duplicate-base]
76 | class E(
| _______^
77 | | A,
78 | | A
79 | | ):
| |_^
80 | # error: [unused-ignore-comment]
81 | x: int # type: ignore[duplicate-base]
|
info: The definition of class `E` will raise `TypeError` at runtime
--> src/mdtest_snippet.py:77:5
|
75 | # error: [duplicate-base]
76 | class E(
77 | A,
| - Class `A` first included in bases list here
78 | A
| ^ Class `A` later repeated here
79 | ):
80 | # error: [unused-ignore-comment]
|
info: `lint:duplicate-base` is enabled by default
```
```
warning: lint:unused-ignore-comment
--> src/mdtest_snippet.py:81:13

View file

@ -71,23 +71,6 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/overloads.md
# Diagnostics
```
error: lint:invalid-overload: Overloaded function `try_from3` does not use the `@classmethod` decorator consistently
--> src/mdtest_snippet.py:40:9
|
38 | def try_from3(cls, x: str) -> None: ...
39 | # error: [invalid-overload]
40 | def try_from3(cls, x: int | str) -> CheckClassMethod | None:
| ---------
| |
| Missing here
41 | if isinstance(x, int):
42 | return cls(x)
|
info: `lint:invalid-overload` is enabled by default
```
```
error: lint:invalid-overload: Overloaded function `try_from1` does not use the `@classmethod` decorator consistently
--> src/mdtest_snippet.py:13:9
@ -129,3 +112,20 @@ error: lint:invalid-overload: Overloaded function `try_from2` does not use the `
info: `lint:invalid-overload` is enabled by default
```
```
error: lint:invalid-overload: Overloaded function `try_from3` does not use the `@classmethod` decorator consistently
--> src/mdtest_snippet.py:40:9
|
38 | def try_from3(cls, x: str) -> None: ...
39 | # error: [invalid-overload]
40 | def try_from3(cls, x: int | str) -> CheckClassMethod | None:
| ---------
| |
| Missing here
41 | if isinstance(x, int):
42 | return cls(x)
|
info: `lint:invalid-overload` is enabled by default
```

View file

@ -64,22 +64,6 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/overloads.md
# Diagnostics
```
error: lint:invalid-overload: `@final` decorator should be applied only to the overload implementation
--> src/mdtest_snippet.py:27:9
|
25 | def method3(self, x: str) -> str: ...
26 | # error: [invalid-overload]
27 | def method3(self, x: int | str) -> int | str:
| -------
| |
| Implementation defined here
28 | return x
|
info: `lint:invalid-overload` is enabled by default
```
```
error: lint:invalid-overload: `@final` decorator should be applied only to the overload implementation
--> src/mdtest_snippet.py:18:9
@ -96,6 +80,22 @@ info: `lint:invalid-overload` is enabled by default
```
```
error: lint:invalid-overload: `@final` decorator should be applied only to the overload implementation
--> src/mdtest_snippet.py:27:9
|
25 | def method3(self, x: str) -> str: ...
26 | # error: [invalid-overload]
27 | def method3(self, x: int | str) -> int | str:
| -------
| |
| Implementation defined here
28 | return x
|
info: `lint:invalid-overload` is enabled by default
```
```
error: lint:invalid-overload: `@final` decorator should be applied only to the first overload
--> src/mdtest_snippet.pyi:11:9

View file

@ -41,6 +41,19 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/protocols.md
# Diagnostics
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:4:1
|
3 | # error: [call-non-callable]
4 | reveal_type(Protocol()) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
5 |
6 | class MyProtocol(Protocol):
|
```
```
error: lint:call-non-callable: Object of type `typing.Protocol` is not callable
--> src/mdtest_snippet.py:4:13
@ -57,14 +70,14 @@ info: `lint:call-non-callable` is enabled by default
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:4:1
|
3 | # error: [call-non-callable]
4 | reveal_type(Protocol()) # revealed: Unknown
| ^^^^^^^^^^^^^^^^^^^^^^^ `Unknown`
5 |
6 | class MyProtocol(Protocol):
|
--> src/mdtest_snippet.py:10:1
|
9 | # error: [call-non-callable] "Cannot instantiate class `MyProtocol`"
10 | reveal_type(MyProtocol()) # revealed: MyProtocol
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `MyProtocol`
11 |
12 | class GenericProtocol[T](Protocol):
|
```
@ -93,13 +106,12 @@ info: `lint:call-non-callable` is enabled by default
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:10:1
--> src/mdtest_snippet.py:16:1
|
9 | # error: [call-non-callable] "Cannot instantiate class `MyProtocol`"
10 | reveal_type(MyProtocol()) # revealed: MyProtocol
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `MyProtocol`
11 |
12 | class GenericProtocol[T](Protocol):
15 | # error: [call-non-callable] "Cannot instantiate class `GenericProtocol`"
16 | reveal_type(GenericProtocol[int]()) # revealed: GenericProtocol[int]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `GenericProtocol[int]`
17 | class SubclassOfMyProtocol(MyProtocol): ...
|
```
@ -126,18 +138,6 @@ info: `lint:call-non-callable` is enabled by default
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:16:1
|
15 | # error: [call-non-callable] "Cannot instantiate class `GenericProtocol`"
16 | reveal_type(GenericProtocol[int]()) # revealed: GenericProtocol[int]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `GenericProtocol[int]`
17 | class SubclassOfMyProtocol(MyProtocol): ...
|
```
```
info: revealed-type: Revealed type
--> src/mdtest_snippet.py:19:1