fix expectations

This commit is contained in:
Aria Desires 2025-12-16 11:44:24 -05:00
parent 4b9755b603
commit 8696a110ff
7 changed files with 19 additions and 19 deletions

View File

@ -57,7 +57,7 @@ We can access attributes on objects of all kinds:
import sys
reveal_type(inspect.getattr_static(sys, "dont_write_bytecode")) # revealed: bool
# revealed: def getattr_static(obj: object, attr: str, default: Any | None = EllipsisType) -> Any
# revealed: def getattr_static(obj: object, attr: str, default: Any | None = ...) -> Any
reveal_type(inspect.getattr_static(inspect, "getattr_static"))
reveal_type(inspect.getattr_static(1, "real")) # revealed: property
@ -144,7 +144,7 @@ from typing import Any
def _(a: Any, tuple_of_any: tuple[Any]):
reveal_type(inspect.getattr_static(a, "x", "default")) # revealed: Any | Literal["default"]
# revealed def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = int, /) -> int
# revealed: def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int
reveal_type(inspect.getattr_static(tuple_of_any, "index", "default"))
```

View File

@ -600,9 +600,9 @@ from typing_extensions import Self
reveal_type(object.__new__) # revealed: def __new__(cls) -> Self@__new__
reveal_type(object().__new__) # revealed: def __new__(cls) -> Self@__new__
# revealed Overload[(cls, x: str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc = 0], /) -> Self@__new__, (cls, x: str | bytes | bytearray, /, base: SupportsIndex) -> Self@__new__
# revealed: Overload[(cls, x: str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc = 0, /) -> Self@__new__, (cls, x: str | bytes | bytearray, /, base: SupportsIndex) -> Self@__new__]
reveal_type(int.__new__)
# revealed Overload[(cls, x: str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc = 0], /) -> Self@__new__, (cls, x: str | bytes | bytearray, /, base: SupportsIndex) -> Self@__new__
# revealed: Overload[(cls, x: str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc = 0, /) -> Self@__new__, (cls, x: str | bytes | bytearray, /, base: SupportsIndex) -> Self@__new__]
reveal_type((42).__new__)
class X:

View File

@ -87,25 +87,25 @@ class C:
def inner_a(positional=self.a):
return
self.a = inner_a
# revealed: def inner_a(positional=Unknown | (def inner_a(positional=Unknown) -> Unknown)) -> Unknown
# revealed: def inner_a(positional=self.a) -> Unknown
reveal_type(inner_a)
def inner_b(*, kw_only=self.b):
return
self.b = inner_b
# revealed: def inner_b(*, kw_only=Unknown | (def inner_b(*, kw_only=Unknown) -> Unknown)) -> Unknown
# revealed: def inner_b(*, kw_only=self.b) -> Unknown
reveal_type(inner_b)
def inner_c(positional_only=self.c, /):
return
self.c = inner_c
# revealed: def inner_c(positional_only=Unknown | (def inner_c(positional_only=Unknown, /) -> Unknown), /) -> Unknown
# revealed: def inner_c(positional_only=self.c, /) -> Unknown
reveal_type(inner_c)
def inner_d(*, kw_only=self.d):
return
self.d = inner_d
# revealed: def inner_d(*, kw_only=Unknown | (def inner_d(*, kw_only=Unknown) -> Unknown)) -> Unknown
# revealed: def inner_d(*, kw_only=self.d) -> Unknown
reveal_type(inner_d)
```
@ -114,7 +114,7 @@ We do, however, still check assignability of the default value to the parameter
```py
class D:
def f(self: "D"):
# error: [invalid-parameter-default] "Default value of type `Unknown | (def inner_a(a: int = Unknown | (def inner_a(a: int = Unknown) -> Unknown)) -> Unknown)` is not assignable to annotated parameter type `int`"
# error: [invalid-parameter-default] "Default value of type `Unknown | (def inner_a(a: int = self.a) -> Unknown)` is not assignable to annotated parameter type `int`"
def inner_a(a: int = self.a): ...
self.a = inner_a
```

View File

@ -221,7 +221,7 @@ class D:
(x): int = 1
# TODO: should ideally not include a `x` parameter
reveal_type(D.__init__) # revealed (self: D, x: int = 1) -> None
reveal_type(D.__init__) # revealed:(self: D, x: int = 1) -> None
```
## `@dataclass` calls with arguments
@ -670,7 +670,7 @@ class A:
a: str = field(kw_only=False)
b: int = 0
reveal_type(A.__init__) # revealed (self: A, a: str, *, b: int = 0) -> None
reveal_type(A.__init__) # revealed:(self: A, a: str, *, b: int = 0) -> None
A("hi")
```
@ -991,7 +991,7 @@ class C:
class_variable1: ClassVar[Final[int]] = 1
class_variable2: ClassVar[Final[int]] = 1
reveal_type(C.__init__) # revealed (self: C, instance_variable_no_default: int, instance_variable: int = 1) -> None
reveal_type(C.__init__) # revealed:(self: C, instance_variable_no_default: int, instance_variable: int = 1) -> None
c = C(1)
# error: [invalid-assignment] "Cannot assign to final attribute `instance_variable` on type `C`"
@ -1082,7 +1082,7 @@ class C(Base):
z: int = 10
x: int = 15
reveal_type(C.__init__) # revealed (self: C, x: int = Literal[15], y: int = Literal[0], z: int = 10) -> None
reveal_type(C.__init__) # revealed:(self: C, x: int = Literal[15], y: int = Literal[0], z: int = 10) -> None
```
## Conditionally defined fields

View File

@ -591,9 +591,9 @@ try:
reveal_type(x) # revealed: B | D
reveal_type(x) # revealed: B | D
x = foo
reveal_type(x) # revealed: def foo(param=A) -> Unknown
reveal_type(x) # revealed: def foo(param=could_raise_returns_A()) -> Unknown
except:
reveal_type(x) # revealed: Literal[1] | (def foo(param=A) -> Unknown)
reveal_type(x) # revealed: Literal[1] | (def foo(param=could_raise_returns_A()) -> Unknown)
class Bar:
x = could_raise_returns_E()
@ -603,9 +603,9 @@ except:
reveal_type(x) # revealed: <class 'Bar'>
finally:
# TODO: should be `Literal[1] | <class 'foo'> | <class 'Bar'>`
reveal_type(x) # revealed: (def foo(param=A) -> Unknown) | <class 'Bar'>
reveal_type(x) # revealed: (def foo(param=could_raise_returns_A()) -> Unknown) | <class 'Bar'>
reveal_type(x) # revealed: (def foo(param=A) -> Unknown) | <class 'Bar'>
reveal_type(x) # revealed: (def foo(param=could_raise_returns_A()) -> Unknown) | <class 'Bar'>
```
[1]: https://astral-sh.notion.site/Exception-handler-control-flow-11348797e1ca80bb8ce1e9aedbbe439d

View File

@ -477,7 +477,7 @@ def keyword_only_with_default_2(*, y: int = 42) -> int:
# parameter list i.e., `()`
# TODO: This shouldn't error
# error: [invalid-argument-type]
# revealed (*, x: int = 42) -> bool
# revealed: (*, x: int = 42) -> bool
reveal_type(multiple(keyword_only_with_default_1, keyword_only_with_default_2))
def keyword_only1(*, x: int) -> int:

View File

@ -97,7 +97,7 @@ inside the module:
import typing
reveal_type(typing.__name__) # revealed: str
reveal_type(typing.__init__) # revealed: bound method ModuleType.__init__(name: str, doc: str | None = EllipsisType) -> None
reveal_type(typing.__init__) # revealed: bound method ModuleType.__init__(name: str, doc: str | None = ...) -> None
# For a stub module, we don't know that `__file__` is a string (at runtime it may be entirely
# unset, but we follow typeshed here):