diff --git a/crates/ty_python_semantic/resources/mdtest/directives/assert_type.md b/crates/ty_python_semantic/resources/mdtest/directives/assert_type.md index b35053ccd54a5..66606e9d87da8 100644 --- a/crates/ty_python_semantic/resources/mdtest/directives/assert_type.md +++ b/crates/ty_python_semantic/resources/mdtest/directives/assert_type.md @@ -42,11 +42,11 @@ from typing_extensions import assert_type # Subtype does not count def _(x: bool): - assert_type(x, int) # error: [type-assertion-failure] "Type `int` does not match asserted type `bool`" + assert_type(x, int) # error: [type-assertion-failure] "Type `bool` does not match asserted type `int`" def _(a: type[int], b: type[Any]): - assert_type(a, type[Any]) # error: [type-assertion-failure] "Type `type[Any]` does not match asserted type `type[int]`" - assert_type(b, type[int]) # error: [type-assertion-failure] "Type `type[int]` does not match asserted type `type[Any]`" + assert_type(a, type[Any]) # error: [type-assertion-failure] "Type `type[int]` does not match asserted type `type[Any]`" + assert_type(b, type[int]) # error: [type-assertion-failure] "Type `type[Any]` does not match asserted type `type[int]`" # The expression constructing the type is not taken into account def _(a: type[int]): @@ -69,9 +69,9 @@ class Bar: ... class Baz: ... def f(x: Foo): - assert_type(x, Bar) # error: [type-assertion-failure] "Type `Bar` does not match asserted type `Foo`" + assert_type(x, Bar) # error: [type-assertion-failure] "Type `Foo` does not match asserted type `Bar`" if isinstance(x, Bar): - assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Bar` does not match asserted type `Foo & Bar`" + assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Foo & Bar` does not match asserted type `Bar`" # The actual type must be a subtype of the asserted type, as well as being unspellable, # in order for `assert-type-unspellable-subtype` to be emitted instead of `type-assertion-failure` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/assert_type.md_-_`assert_type`_-_Unspellable_types_(385d082f9803b184).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/assert_type.md_-_`assert_type`_-_Unspellable_types_(385d082f9803b184).snap index b0fdb5898322d..9a32be1187f27 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/assert_type.md_-_`assert_type`_-_Unspellable_types_(385d082f9803b184).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/assert_type.md_-_`assert_type`_-_Unspellable_types_(385d082f9803b184).snap @@ -20,9 +20,9 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/directives/assert_type.m 5 | class Baz: ... 6 | 7 | def f(x: Foo): - 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Bar` does not match asserted type `Foo`" + 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Foo` does not match asserted type `Bar`" 9 | if isinstance(x, Bar): -10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Bar` does not match asserted type `Foo & Bar`" +10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Foo & Bar` does not match asserted type `Bar`" 11 | 12 | # The actual type must be a subtype of the asserted type, as well as being unspellable, 13 | # in order for `assert-type-unspellable-subtype` to be emitted instead of `type-assertion-failure` @@ -36,12 +36,12 @@ error[type-assertion-failure]: Argument does not have asserted type `Bar` --> src/mdtest_snippet.py:8:5 | 7 | def f(x: Foo): - 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Bar` does not match asserted type `Foo`" + 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Foo` does not match asserted type `Bar`" | ^^^^^^^^^^^^-^^^^^^ | | | Inferred type is `Foo` 9 | if isinstance(x, Bar): -10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Bar` does not match asserted type `Foo & Bar`" +10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Foo & Bar` does not match asserted type `Bar`" | info: `Bar` and `Foo` are not equivalent types info: rule `type-assertion-failure` is enabled by default @@ -52,9 +52,9 @@ info: rule `type-assertion-failure` is enabled by default error[assert-type-unspellable-subtype]: Argument does not have asserted type `Bar` --> src/mdtest_snippet.py:10:9 | - 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Bar` does not match asserted type `Foo`" + 8 | assert_type(x, Bar) # error: [type-assertion-failure] "Type `Foo` does not match asserted type `Bar`" 9 | if isinstance(x, Bar): -10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Bar` does not match asserted type `Foo & Bar`" +10 | assert_type(x, Bar) # error: [assert-type-unspellable-subtype] "Type `Foo & Bar` does not match asserted type `Bar`" | ^^^^^^^^^^^^-^^^^^^ | | | Inferred type is `Foo & Bar` diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 7362de61c6a51..f82a45b489576 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -1774,8 +1774,8 @@ impl KnownFunction { diagnostic.set_concise_message(format_args!( "Type `{}` does not match asserted type `{}`", - asserted_ty.display(db), actual_ty.display(db), + asserted_ty.display(db), )); } } diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__publish_diagnostics__message_without_related_information_support.snap b/crates/ty_server/tests/e2e/snapshots/e2e__publish_diagnostics__message_without_related_information_support.snap index d2056ebf20fcf..fe24d5e7debf9 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__publish_diagnostics__message_without_related_information_support.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__publish_diagnostics__message_without_related_information_support.snap @@ -58,7 +58,7 @@ PublishDiagnosticsParams { source: Some( "ty", ), - message: "Type `list[str]` does not match asserted type `Literal[/"test/"]`", + message: "Type `Literal[/"test/"]` does not match asserted type `list[str]`", related_information: None, tags: None, data: None,