diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md index 4af89f9d2a..5d349e5034 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md @@ -144,7 +144,7 @@ class Dict[T](TypedDict): type DictInt = Dict[int] -# error: [non-subscriptable] "Cannot subscript non-generic type alias: `Dict` is already specialized" +# error: [non-subscriptable] "Cannot subscript non-generic type alias: `Dict[int]` is already specialized" def _(x: DictInt[int]): reveal_type(x) # revealed: Unknown diff --git a/crates/ty_python_semantic/resources/mdtest/typed_dict.md b/crates/ty_python_semantic/resources/mdtest/typed_dict.md index 91e957298c..961c542ee1 100644 --- a/crates/ty_python_semantic/resources/mdtest/typed_dict.md +++ b/crates/ty_python_semantic/resources/mdtest/typed_dict.md @@ -1446,7 +1446,7 @@ class TaggedData(TypedDict, Generic[T]): p1: TaggedData[int] = {"data": 42, "tag": "number"} p2: TaggedData[str] = {"data": "Hello", "tag": "text"} -# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData`: value of type `Literal["not a number"]`" +# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData[int]`: value of type `Literal["not a number"]`" p3: TaggedData[int] = {"data": "not a number", "tag": "number"} class Items(TypedDict, Generic[T]): @@ -1488,7 +1488,7 @@ class TaggedData[T](TypedDict): p1: TaggedData[int] = {"data": 42, "tag": "number"} p2: TaggedData[str] = {"data": "Hello", "tag": "text"} -# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData`: value of type `Literal["not a number"]`" +# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData[int]`: value of type `Literal["not a number"]`" p3: TaggedData[int] = {"data": "not a number", "tag": "number"} class Items[T](TypedDict): diff --git a/crates/ty_python_semantic/src/types/display.rs b/crates/ty_python_semantic/src/types/display.rs index 3eeb14c86a..197ed5dca2 100644 --- a/crates/ty_python_semantic/src/types/display.rs +++ b/crates/ty_python_semantic/src/types/display.rs @@ -980,11 +980,14 @@ impl<'db> FmtDetailed<'db> for DisplayRepresentation<'db> { } f.write_str("]") } - Type::TypedDict(TypedDictType::Class(defining_class)) => defining_class - .class_literal(self.db) - .0 - .display_with(self.db, self.settings.clone()) - .fmt_detailed(f), + Type::TypedDict(TypedDictType::Class(defining_class)) => match defining_class { + ClassType::NonGeneric(class) => class + .display_with(self.db, self.settings.clone()) + .fmt_detailed(f), + ClassType::Generic(alias) => alias + .display_with(self.db, self.settings.clone()) + .fmt_detailed(f), + }, Type::TypedDict(TypedDictType::Synthesized(synthesized)) => { f.set_invalid_type_annotation(); f.write_char('<')?; diff --git a/crates/ty_python_semantic/src/types/typed_dict.rs b/crates/ty_python_semantic/src/types/typed_dict.rs index 577e146dfa..1b98da3db8 100644 --- a/crates/ty_python_semantic/src/types/typed_dict.rs +++ b/crates/ty_python_semantic/src/types/typed_dict.rs @@ -556,7 +556,7 @@ impl TypedDictAssignmentKind { /// Validates assignment of a value to a specific key on a `TypedDict`. /// /// Returns true if the assignment is valid, or false otherwise. -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] pub(super) fn validate_typed_dict_key_assignment<'db, 'ast>( context: &InferContext<'db, 'ast>, typed_dict: TypedDictType<'db>,