From 8696a110ff6b3813bda9580f776d5b6a06389053 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Tue, 16 Dec 2025 11:44:24 -0500 Subject: [PATCH] fix expectations --- .../resources/mdtest/call/getattr_static.md | 4 ++-- .../resources/mdtest/call/methods.md | 4 ++-- crates/ty_python_semantic/resources/mdtest/cycle.md | 10 +++++----- .../resources/mdtest/dataclasses/dataclasses.md | 8 ++++---- .../resources/mdtest/exception/control_flow.md | 8 ++++---- .../resources/mdtest/generics/pep695/paramspec.md | 2 +- .../resources/mdtest/scopes/moduletype_attrs.md | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/call/getattr_static.md b/crates/ty_python_semantic/resources/mdtest/call/getattr_static.md index c8c42793d0..ba117b769e 100644 --- a/crates/ty_python_semantic/resources/mdtest/call/getattr_static.md +++ b/crates/ty_python_semantic/resources/mdtest/call/getattr_static.md @@ -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")) ``` diff --git a/crates/ty_python_semantic/resources/mdtest/call/methods.md b/crates/ty_python_semantic/resources/mdtest/call/methods.md index 74eecad4fb..fd5d8dfc56 100644 --- a/crates/ty_python_semantic/resources/mdtest/call/methods.md +++ b/crates/ty_python_semantic/resources/mdtest/call/methods.md @@ -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: diff --git a/crates/ty_python_semantic/resources/mdtest/cycle.md b/crates/ty_python_semantic/resources/mdtest/cycle.md index d4cc2bd3ec..cf62255868 100644 --- a/crates/ty_python_semantic/resources/mdtest/cycle.md +++ b/crates/ty_python_semantic/resources/mdtest/cycle.md @@ -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 ``` diff --git a/crates/ty_python_semantic/resources/mdtest/dataclasses/dataclasses.md b/crates/ty_python_semantic/resources/mdtest/dataclasses/dataclasses.md index 3e8837aba6..2751081e3b 100644 --- a/crates/ty_python_semantic/resources/mdtest/dataclasses/dataclasses.md +++ b/crates/ty_python_semantic/resources/mdtest/dataclasses/dataclasses.md @@ -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 diff --git a/crates/ty_python_semantic/resources/mdtest/exception/control_flow.md b/crates/ty_python_semantic/resources/mdtest/exception/control_flow.md index fe1e253c31..f52f3839e2 100644 --- a/crates/ty_python_semantic/resources/mdtest/exception/control_flow.md +++ b/crates/ty_python_semantic/resources/mdtest/exception/control_flow.md @@ -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: finally: # TODO: should be `Literal[1] | | ` - reveal_type(x) # revealed: (def foo(param=A) -> Unknown) | + reveal_type(x) # revealed: (def foo(param=could_raise_returns_A()) -> Unknown) | -reveal_type(x) # revealed: (def foo(param=A) -> Unknown) | +reveal_type(x) # revealed: (def foo(param=could_raise_returns_A()) -> Unknown) | ``` [1]: https://astral-sh.notion.site/Exception-handler-control-flow-11348797e1ca80bb8ce1e9aedbbe439d diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md index c3373c9118..fa5f6f253f 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md @@ -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: diff --git a/crates/ty_python_semantic/resources/mdtest/scopes/moduletype_attrs.md b/crates/ty_python_semantic/resources/mdtest/scopes/moduletype_attrs.md index 3f84588803..2b1419f19d 100644 --- a/crates/ty_python_semantic/resources/mdtest/scopes/moduletype_attrs.md +++ b/crates/ty_python_semantic/resources/mdtest/scopes/moduletype_attrs.md @@ -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):