diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md index 53f652d37a..1082e105d5 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md @@ -395,12 +395,19 @@ class C[T]: def __init__[S](self, x: T, y: S) -> None: ... -# TODO: need to handle self in __init__ call. -reveal_type(C(1, 1)) # revealed: C[int] -reveal_type(C(1, "string")) # revealed: C[int] -reveal_type(C(1, True)) # revealed: C[int] +# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 +# error: [invalid-argument-type] "Argument to bound method `__init__` is incorrect: Expected `Self@__init__`, found `C[int]`" +reveal_type(C(1, 1)) # revealed: C[Unknown] +# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 +# error: [invalid-argument-type] +reveal_type(C(1, "string")) # revealed: C[Unknown] +# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 +# error: [invalid-argument-type] +reveal_type(C(1, True)) # revealed: C[Unknown] -# error: [invalid-assignment] "Object of type `C[str]` is not assignable to `C[int]`" +# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 +# The correct error should be [invalid-assignment] "Object of type `C[str]` is not assignable to `C[int]`" +# error: [invalid-argument-type] wrong_innards: C[int] = C("five", 1) ``` @@ -519,6 +526,8 @@ reveal_type(generic_context(C[int].method)) # revealed: tuple[Self@method] reveal_type(generic_context(C[int].generic_method)) # revealed: tuple[U@generic_method] c: C[int] = C[int]() +# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 +# error: [invalid-argument-type] reveal_type(c.generic_method(1, "string")) # revealed: Literal["string"] reveal_type(generic_context(c)) # revealed: None reveal_type(generic_context(c.method)) # revealed: tuple[Self@method] diff --git a/crates/ty_python_semantic/resources/mdtest/pep695_type_aliases.md b/crates/ty_python_semantic/resources/mdtest/pep695_type_aliases.md index 097b6c347b..cd98d6f751 100644 --- a/crates/ty_python_semantic/resources/mdtest/pep695_type_aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/pep695_type_aliases.md @@ -299,7 +299,7 @@ type A = list[Union["A", str]] def f(x: A): reveal_type(x) # revealed: list[A | str] for item in x: - reveal_type(item) # revealed: list[A | str] | str + reveal_type(item) # revealed: list[Any | str] | str ``` #### With new-style union @@ -310,7 +310,7 @@ type A = list["A" | str] def f(x: A): reveal_type(x) # revealed: list[A | str] for item in x: - reveal_type(item) # revealed: list[A | str] | str + reveal_type(item) # revealed: list[Any | str] | str ``` #### With Optional @@ -323,5 +323,5 @@ type A = list[Optional[Union["A", str]]] def f(x: A): reveal_type(x) # revealed: list[A | str | None] for item in x: - reveal_type(item) # revealed: list[A | str | None] | str | None + reveal_type(item) # revealed: list[Any | str | None] | str | None ``` diff --git a/crates/ty_python_semantic/resources/mdtest/protocols.md b/crates/ty_python_semantic/resources/mdtest/protocols.md index 7e4e710f09..261100552c 100644 --- a/crates/ty_python_semantic/resources/mdtest/protocols.md +++ b/crates/ty_python_semantic/resources/mdtest/protocols.md @@ -1809,6 +1809,7 @@ class P4(Protocol): @z.setter def z(self, value: int) -> None: ... +# error: [static-assert-error] static_assert(is_equivalent_to(P1, P2)) # TODO: should pass @@ -1822,6 +1823,7 @@ differently ordered unions: class A: ... class B: ... +# error: [static-assert-error] static_assert(is_equivalent_to(A | B | P1, P2 | B | A)) # TODO: should pass diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index 8528cc41f0..d6b8bb1712 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -1202,22 +1202,12 @@ impl<'db> Parameters<'db> { let positional_or_keyword = args.iter().map(|arg| { // TODO(https://github.com/astral-sh/ty/issues/159): Also set the type for `cls` argument - // eprintln!( - // "arg {}: pos: {:?}, is_static: {}, is_class: {}, anno: {:?}", - // arg.name().id.as_str(), - // parameters.index(arg.name().id()), - // is_staticmethod, - // is_classmethod, - // arg.parameter.annotation() - // ); - // dbg!(is_method); if is_method && !is_staticmethod && !is_classmethod && arg.parameter.annotation().is_none() && parameters.index(arg.name().id()) == Some(0) { - eprintln!("arg {} is self", arg.name().id.as_str()); let implicit_annotation = Type::SpecialForm(SpecialFormType::TypingSelf) .in_type_expression(db, definition.scope(db), Some(definition)) .ok(); @@ -1231,7 +1221,6 @@ impl<'db> Parameters<'db> { form: ParameterForm::Value, } } else { - eprintln!("arg {} is not self", arg.name().id.as_str()); Parameter::from_node_and_kind( db, definition,