Update tests

This commit is contained in:
David Peter 2025-09-08 15:49:40 +02:00
parent f0b0d2ef87
commit 31566d67cb
3 changed files with 8 additions and 22 deletions

View File

@ -395,19 +395,11 @@ class C[T]:
def __init__[S](self, x: T, y: S) -> None: ... def __init__[S](self, x: T, y: S) -> None: ...
# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 reveal_type(C(1, 1)) # revealed: C[int]
# error: [invalid-argument-type] "Argument to bound method `__init__` is incorrect: Expected `Self@__init__`, found `C[int]`" reveal_type(C(1, "string")) # revealed: C[int]
reveal_type(C(1, 1)) # revealed: C[Unknown] 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]
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]
# TODO: there should be no error https://github.com/astral-sh/ty/issues/1131 # error: [invalid-assignment] "Object of type `C[str]` is not assignable to `C[int]"
# 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) wrong_innards: C[int] = C("five", 1)
``` ```
@ -520,18 +512,16 @@ class C[T]:
reveal_type(generic_context(C)) # revealed: tuple[T@C] reveal_type(generic_context(C)) # revealed: tuple[T@C]
reveal_type(generic_context(C.method)) # revealed: tuple[Self@method] reveal_type(generic_context(C.method)) # revealed: tuple[Self@method]
reveal_type(generic_context(C.generic_method)) # revealed: tuple[U@generic_method] reveal_type(generic_context(C.generic_method)) # revealed: tuple[Self@generic_method, U@generic_method]
reveal_type(generic_context(C[int])) # revealed: None reveal_type(generic_context(C[int])) # revealed: None
reveal_type(generic_context(C[int].method)) # revealed: tuple[Self@method] reveal_type(generic_context(C[int].method)) # revealed: tuple[Self@method]
reveal_type(generic_context(C[int].generic_method)) # revealed: tuple[U@generic_method] reveal_type(generic_context(C[int].generic_method)) # revealed: tuple[Self@generic_method, U@generic_method]
c: C[int] = C[int]() 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(c.generic_method(1, "string")) # revealed: Literal["string"]
reveal_type(generic_context(c)) # revealed: None reveal_type(generic_context(c)) # revealed: None
reveal_type(generic_context(c.method)) # revealed: tuple[Self@method] reveal_type(generic_context(c.method)) # revealed: tuple[Self@method]
reveal_type(generic_context(c.generic_method)) # revealed: tuple[U@generic_method] reveal_type(generic_context(c.generic_method)) # revealed: tuple[Self@generic_method, U@generic_method]
``` ```
## Specializations propagate ## Specializations propagate

View File

@ -512,7 +512,5 @@ class C:
def _(x: int): def _(x: int):
reveal_type(C().explicit_self(x)) # revealed: tuple[C, int] reveal_type(C().explicit_self(x)) # revealed: tuple[C, int]
reveal_type(C().implicit_self(x)) # revealed: tuple[C, int]
# TODO: this should be `tuple[C, int]` as well, once we support implicit `self`
reveal_type(C().implicit_self(x)) # revealed: tuple[Unknown, int]
``` ```

View File

@ -168,8 +168,6 @@ class C[T]:
c: C[int] = C() c: C[int] = C()
# TODO:
# error: [invalid-argument-type] "Argument to bound method `m` is incorrect: Expected `Self@m`, found `C[Unknown]`"
reveal_type(c.m(1, "string")) # revealed: Literal["string"] reveal_type(c.m(1, "string")) # revealed: Literal["string"]
``` ```