diff --git a/conformance/third_party/conformance.exp b/conformance/third_party/conformance.exp index 9370d5bfea..772c467202 100644 --- a/conformance/third_party/conformance.exp +++ b/conformance/third_party/conformance.exp @@ -2228,7 +2228,7 @@ "code": -2, "column": 25, "concise_description": "`Proto8` is not assignable to `Proto5[Any]`", - "description": "`Proto8` is not assignable to `Proto5[Any]`\n `Proto8.__call__` has type `(self: Proto8) -> None`, which is not assignable to `(self: Proto8, *args: Any, **kwargs: Any) -> None`, the type of `Proto5.__call__`", + "description": "`Proto8` is not assignable to `Proto5[Any]`\n `Proto8.__call__` has type `() -> None`, which is not assignable to `(*args: Any, **kwargs: Any) -> None`, the type of `Proto5.__call__`", "line": 159, "name": "bad-assignment", "severity": "error", @@ -2674,7 +2674,7 @@ "code": -2, "column": 21, "concise_description": "`PosOnly2` is not assignable to `Standard2`", - "description": "`PosOnly2` is not assignable to `Standard2`\n `PosOnly2.__call__` has type `(self: PosOnly2, b: int, a: int, /) -> None`, which is not assignable to `(self: PosOnly2, a: int, b: int) -> None`, the type of `Standard2.__call__`", + "description": "`PosOnly2` is not assignable to `Standard2`\n `PosOnly2.__call__` has type `(b: int, a: int, /) -> None`, which is not assignable to `(a: int, b: int) -> None`, the type of `Standard2.__call__`", "line": 51, "name": "bad-assignment", "severity": "error", @@ -2685,7 +2685,7 @@ "code": -2, "column": 21, "concise_description": "`KwOnly2` is not assignable to `Standard2`", - "description": "`KwOnly2` is not assignable to `Standard2`\n `KwOnly2.__call__` has type `(self: KwOnly2, *, b: int, a: int) -> None`, which is not assignable to `(self: KwOnly2, a: int, b: int) -> None`, the type of `Standard2.__call__`", + "description": "`KwOnly2` is not assignable to `Standard2`\n `KwOnly2.__call__` has type `(*, b: int, a: int) -> None`, which is not assignable to `(a: int, b: int) -> None`, the type of `Standard2.__call__`", "line": 52, "name": "bad-assignment", "severity": "error", @@ -2696,7 +2696,7 @@ "code": -2, "column": 20, "concise_description": "`KwOnly2` is not assignable to `PosOnly2`", - "description": "`KwOnly2` is not assignable to `PosOnly2`\n `KwOnly2.__call__` has type `(self: KwOnly2, *, b: int, a: int) -> None`, which is not assignable to `(self: KwOnly2, b: int, a: int, /) -> None`, the type of `PosOnly2.__call__`", + "description": "`KwOnly2` is not assignable to `PosOnly2`\n `KwOnly2.__call__` has type `(*, b: int, a: int) -> None`, which is not assignable to `(b: int, a: int, /) -> None`, the type of `PosOnly2.__call__`", "line": 55, "name": "bad-assignment", "severity": "error", @@ -2707,7 +2707,7 @@ "code": -2, "column": 19, "concise_description": "`PosOnly2` is not assignable to `KwOnly2`", - "description": "`PosOnly2` is not assignable to `KwOnly2`\n `PosOnly2.__call__` has type `(self: PosOnly2, b: int, a: int, /) -> None`, which is not assignable to `(self: PosOnly2, *, b: int, a: int) -> None`, the type of `KwOnly2.__call__`", + "description": "`PosOnly2` is not assignable to `KwOnly2`\n `PosOnly2.__call__` has type `(b: int, a: int, /) -> None`, which is not assignable to `(*, b: int, a: int) -> None`, the type of `KwOnly2.__call__`", "line": 58, "name": "bad-assignment", "severity": "error", @@ -2718,7 +2718,7 @@ "code": -2, "column": 20, "concise_description": "`NoArgs3` is not assignable to `IntArgs3`", - "description": "`NoArgs3` is not assignable to `IntArgs3`\n `NoArgs3.__call__` has type `(self: NoArgs3) -> None`, which is not assignable to `(self: NoArgs3, *args: int) -> None`, the type of `IntArgs3.__call__`", + "description": "`NoArgs3` is not assignable to `IntArgs3`\n `NoArgs3.__call__` has type `() -> None`, which is not assignable to `(*args: int) -> None`, the type of `IntArgs3.__call__`", "line": 82, "name": "bad-assignment", "severity": "error", @@ -2729,7 +2729,7 @@ "code": -2, "column": 22, "concise_description": "`NoArgs3` is not assignable to `FloatArgs3`", - "description": "`NoArgs3` is not assignable to `FloatArgs3`\n `NoArgs3.__call__` has type `(self: NoArgs3) -> None`, which is not assignable to `(self: NoArgs3, *args: float) -> None`, the type of `FloatArgs3.__call__`", + "description": "`NoArgs3` is not assignable to `FloatArgs3`\n `NoArgs3.__call__` has type `() -> None`, which is not assignable to `(*args: float) -> None`, the type of `FloatArgs3.__call__`", "line": 85, "name": "bad-assignment", "severity": "error", @@ -2740,7 +2740,7 @@ "code": -2, "column": 22, "concise_description": "`IntArgs3` is not assignable to `FloatArgs3`", - "description": "`IntArgs3` is not assignable to `FloatArgs3`\n `IntArgs3.__call__` has type `(self: IntArgs3, *args: int) -> None`, which is not assignable to `(self: IntArgs3, *args: float) -> None`, the type of `FloatArgs3.__call__`", + "description": "`IntArgs3` is not assignable to `FloatArgs3`\n `IntArgs3.__call__` has type `(*args: int) -> None`, which is not assignable to `(*args: float) -> None`, the type of `FloatArgs3.__call__`", "line": 86, "name": "bad-assignment", "severity": "error", @@ -2751,7 +2751,7 @@ "code": -2, "column": 20, "concise_description": "`IntArgs4` is not assignable to `PosOnly4`", - "description": "`IntArgs4` is not assignable to `PosOnly4`\n `IntArgs4.__call__` has type `(self: IntArgs4, *args: int) -> None`, which is not assignable to `(self: IntArgs4, a: int, b: str, /) -> None`, the type of `PosOnly4.__call__`", + "description": "`IntArgs4` is not assignable to `PosOnly4`\n `IntArgs4.__call__` has type `(*args: int) -> None`, which is not assignable to `(a: int, b: str, /) -> None`, the type of `PosOnly4.__call__`", "line": 116, "name": "bad-assignment", "severity": "error", @@ -2762,7 +2762,7 @@ "code": -2, "column": 23, "concise_description": "`StrArgs4` is not assignable to `IntStrArgs4`", - "description": "`StrArgs4` is not assignable to `IntStrArgs4`\n `StrArgs4.__call__` has type `(self: StrArgs4, a: int, /, *args: str) -> None`, which is not assignable to `(self: StrArgs4, *args: int | str) -> None`, the type of `IntStrArgs4.__call__`", + "description": "`StrArgs4` is not assignable to `IntStrArgs4`\n `StrArgs4.__call__` has type `(a: int, /, *args: str) -> None`, which is not assignable to `(*args: int | str) -> None`, the type of `IntStrArgs4.__call__`", "line": 119, "name": "bad-assignment", "severity": "error", @@ -2773,7 +2773,7 @@ "code": -2, "column": 23, "concise_description": "`IntArgs4` is not assignable to `IntStrArgs4`", - "description": "`IntArgs4` is not assignable to `IntStrArgs4`\n `IntArgs4.__call__` has type `(self: IntArgs4, *args: int) -> None`, which is not assignable to `(self: IntArgs4, *args: int | str) -> None`, the type of `IntStrArgs4.__call__`", + "description": "`IntArgs4` is not assignable to `IntStrArgs4`\n `IntArgs4.__call__` has type `(*args: int) -> None`, which is not assignable to `(*args: int | str) -> None`, the type of `IntStrArgs4.__call__`", "line": 120, "name": "bad-assignment", "severity": "error", @@ -2784,7 +2784,7 @@ "code": -2, "column": 20, "concise_description": "`IntArgs4` is not assignable to `StrArgs4`", - "description": "`IntArgs4` is not assignable to `StrArgs4`\n `IntArgs4.__call__` has type `(self: IntArgs4, *args: int) -> None`, which is not assignable to `(self: IntArgs4, a: int, /, *args: str) -> None`, the type of `StrArgs4.__call__`", + "description": "`IntArgs4` is not assignable to `StrArgs4`\n `IntArgs4.__call__` has type `(*args: int) -> None`, which is not assignable to `(a: int, /, *args: str) -> None`, the type of `StrArgs4.__call__`", "line": 122, "name": "bad-assignment", "severity": "error", @@ -2795,7 +2795,7 @@ "code": -2, "column": 20, "concise_description": "`StrArgs4` is not assignable to `IntArgs4`", - "description": "`StrArgs4` is not assignable to `IntArgs4`\n `StrArgs4.__call__` has type `(self: StrArgs4, a: int, /, *args: str) -> None`, which is not assignable to `(self: StrArgs4, *args: int) -> None`, the type of `IntArgs4.__call__`", + "description": "`StrArgs4` is not assignable to `IntArgs4`\n `StrArgs4.__call__` has type `(a: int, /, *args: str) -> None`, which is not assignable to `(*args: int) -> None`, the type of `IntArgs4.__call__`", "line": 124, "name": "bad-assignment", "severity": "error", @@ -2806,7 +2806,7 @@ "code": -2, "column": 22, "concise_description": "`IntStrArgs4` is not assignable to `Standard4`", - "description": "`IntStrArgs4` is not assignable to `Standard4`\n `IntStrArgs4.__call__` has type `(self: IntStrArgs4, *args: int | str) -> None`, which is not assignable to `(self: IntStrArgs4, a: int, b: str) -> None`, the type of `Standard4.__call__`", + "description": "`IntStrArgs4` is not assignable to `Standard4`\n `IntStrArgs4.__call__` has type `(*args: int | str) -> None`, which is not assignable to `(a: int, b: str) -> None`, the type of `Standard4.__call__`", "line": 125, "name": "bad-assignment", "severity": "error", @@ -2817,7 +2817,7 @@ "code": -2, "column": 22, "concise_description": "`StrArgs4` is not assignable to `Standard4`", - "description": "`StrArgs4` is not assignable to `Standard4`\n `StrArgs4.__call__` has type `(self: StrArgs4, a: int, /, *args: str) -> None`, which is not assignable to `(self: StrArgs4, a: int, b: str) -> None`, the type of `Standard4.__call__`", + "description": "`StrArgs4` is not assignable to `Standard4`\n `StrArgs4.__call__` has type `(a: int, /, *args: str) -> None`, which is not assignable to `(a: int, b: str) -> None`, the type of `Standard4.__call__`", "line": 126, "name": "bad-assignment", "severity": "error", @@ -2828,7 +2828,7 @@ "code": -2, "column": 22, "concise_description": "`NoKwargs5` is not assignable to `IntKwargs5`", - "description": "`NoKwargs5` is not assignable to `IntKwargs5`\n `NoKwargs5.__call__` has type `(self: NoKwargs5) -> None`, which is not assignable to `(self: NoKwargs5, **kwargs: int) -> None`, the type of `IntKwargs5.__call__`", + "description": "`NoKwargs5` is not assignable to `IntKwargs5`\n `NoKwargs5.__call__` has type `() -> None`, which is not assignable to `(**kwargs: int) -> None`, the type of `IntKwargs5.__call__`", "line": 151, "name": "bad-assignment", "severity": "error", @@ -2839,7 +2839,7 @@ "code": -2, "column": 24, "concise_description": "`NoKwargs5` is not assignable to `FloatKwargs5`", - "description": "`NoKwargs5` is not assignable to `FloatKwargs5`\n `NoKwargs5.__call__` has type `(self: NoKwargs5) -> None`, which is not assignable to `(self: NoKwargs5, **kwargs: float) -> None`, the type of `FloatKwargs5.__call__`", + "description": "`NoKwargs5` is not assignable to `FloatKwargs5`\n `NoKwargs5.__call__` has type `() -> None`, which is not assignable to `(**kwargs: float) -> None`, the type of `FloatKwargs5.__call__`", "line": 154, "name": "bad-assignment", "severity": "error", @@ -2850,7 +2850,7 @@ "code": -2, "column": 24, "concise_description": "`IntKwargs5` is not assignable to `FloatKwargs5`", - "description": "`IntKwargs5` is not assignable to `FloatKwargs5`\n `IntKwargs5.__call__` has type `(self: IntKwargs5, **kwargs: int) -> None`, which is not assignable to `(self: IntKwargs5, **kwargs: float) -> None`, the type of `FloatKwargs5.__call__`", + "description": "`IntKwargs5` is not assignable to `FloatKwargs5`\n `IntKwargs5.__call__` has type `(**kwargs: int) -> None`, which is not assignable to `(**kwargs: float) -> None`, the type of `FloatKwargs5.__call__`", "line": 155, "name": "bad-assignment", "severity": "error", @@ -2861,7 +2861,7 @@ "code": -2, "column": 19, "concise_description": "`IntKwargs6` is not assignable to `KwOnly6`", - "description": "`IntKwargs6` is not assignable to `KwOnly6`\n `IntKwargs6.__call__` has type `(self: IntKwargs6, **kwargs: int) -> None`, which is not assignable to `(self: IntKwargs6, *, a: int, b: str) -> None`, the type of `KwOnly6.__call__`", + "description": "`IntKwargs6` is not assignable to `KwOnly6`\n `IntKwargs6.__call__` has type `(**kwargs: int) -> None`, which is not assignable to `(*, a: int, b: str) -> None`, the type of `KwOnly6.__call__`", "line": 187, "name": "bad-assignment", "severity": "error", @@ -2872,7 +2872,7 @@ "code": -2, "column": 25, "concise_description": "`StrKwargs6` is not assignable to `IntStrKwargs6`", - "description": "`StrKwargs6` is not assignable to `IntStrKwargs6`\n `StrKwargs6.__call__` has type `(self: StrKwargs6, *, a: int, **kwargs: str) -> None`, which is not assignable to `(self: StrKwargs6, **kwargs: int | str) -> None`, the type of `IntStrKwargs6.__call__`", + "description": "`StrKwargs6` is not assignable to `IntStrKwargs6`\n `StrKwargs6.__call__` has type `(*, a: int, **kwargs: str) -> None`, which is not assignable to `(**kwargs: int | str) -> None`, the type of `IntStrKwargs6.__call__`", "line": 190, "name": "bad-assignment", "severity": "error", @@ -2883,7 +2883,7 @@ "code": -2, "column": 25, "concise_description": "`IntKwargs6` is not assignable to `IntStrKwargs6`", - "description": "`IntKwargs6` is not assignable to `IntStrKwargs6`\n `IntKwargs6.__call__` has type `(self: IntKwargs6, **kwargs: int) -> None`, which is not assignable to `(self: IntKwargs6, **kwargs: int | str) -> None`, the type of `IntStrKwargs6.__call__`", + "description": "`IntKwargs6` is not assignable to `IntStrKwargs6`\n `IntKwargs6.__call__` has type `(**kwargs: int) -> None`, which is not assignable to `(**kwargs: int | str) -> None`, the type of `IntStrKwargs6.__call__`", "line": 191, "name": "bad-assignment", "severity": "error", @@ -2894,7 +2894,7 @@ "code": -2, "column": 22, "concise_description": "`IntKwargs6` is not assignable to `StrKwargs6`", - "description": "`IntKwargs6` is not assignable to `StrKwargs6`\n `IntKwargs6.__call__` has type `(self: IntKwargs6, **kwargs: int) -> None`, which is not assignable to `(self: IntKwargs6, *, a: int, **kwargs: str) -> None`, the type of `StrKwargs6.__call__`", + "description": "`IntKwargs6` is not assignable to `StrKwargs6`\n `IntKwargs6.__call__` has type `(**kwargs: int) -> None`, which is not assignable to `(*, a: int, **kwargs: str) -> None`, the type of `StrKwargs6.__call__`", "line": 193, "name": "bad-assignment", "severity": "error", @@ -2905,7 +2905,7 @@ "code": -2, "column": 22, "concise_description": "`StrKwargs6` is not assignable to `IntKwargs6`", - "description": "`StrKwargs6` is not assignable to `IntKwargs6`\n `StrKwargs6.__call__` has type `(self: StrKwargs6, *, a: int, **kwargs: str) -> None`, which is not assignable to `(self: StrKwargs6, **kwargs: int) -> None`, the type of `IntKwargs6.__call__`", + "description": "`StrKwargs6` is not assignable to `IntKwargs6`\n `StrKwargs6.__call__` has type `(*, a: int, **kwargs: str) -> None`, which is not assignable to `(**kwargs: int) -> None`, the type of `IntKwargs6.__call__`", "line": 195, "name": "bad-assignment", "severity": "error", @@ -2916,7 +2916,7 @@ "code": -2, "column": 22, "concise_description": "`IntStrKwargs6` is not assignable to `Standard6`", - "description": "`IntStrKwargs6` is not assignable to `Standard6`\n `IntStrKwargs6.__call__` has type `(self: IntStrKwargs6, **kwargs: int | str) -> None`, which is not assignable to `(self: IntStrKwargs6, a: int, b: str) -> None`, the type of `Standard6.__call__`", + "description": "`IntStrKwargs6` is not assignable to `Standard6`\n `IntStrKwargs6.__call__` has type `(**kwargs: int | str) -> None`, which is not assignable to `(a: int, b: str) -> None`, the type of `Standard6.__call__`", "line": 196, "name": "bad-assignment", "severity": "error", @@ -2927,7 +2927,7 @@ "code": -2, "column": 22, "concise_description": "`StrKwargs6` is not assignable to `Standard6`", - "description": "`StrKwargs6` is not assignable to `Standard6`\n `StrKwargs6.__call__` has type `(self: StrKwargs6, *, a: int, **kwargs: str) -> None`, which is not assignable to `(self: StrKwargs6, a: int, b: str) -> None`, the type of `Standard6.__call__`", + "description": "`StrKwargs6` is not assignable to `Standard6`\n `StrKwargs6.__call__` has type `(*, a: int, **kwargs: str) -> None`, which is not assignable to `(a: int, b: str) -> None`, the type of `Standard6.__call__`", "line": 197, "name": "bad-assignment", "severity": "error", @@ -2938,7 +2938,7 @@ "code": -2, "column": 23, "concise_description": "`NoDefaultArg8` is not assignable to `DefaultArg8`", - "description": "`NoDefaultArg8` is not assignable to `DefaultArg8`\n `NoDefaultArg8.__call__` has type `(self: NoDefaultArg8, x: int) -> None`, which is not assignable to `(self: NoDefaultArg8, x: int = 0) -> None`, the type of `DefaultArg8.__call__`", + "description": "`NoDefaultArg8` is not assignable to `DefaultArg8`\n `NoDefaultArg8.__call__` has type `(x: int) -> None`, which is not assignable to `(x: int = 0) -> None`, the type of `DefaultArg8.__call__`", "line": 236, "name": "bad-assignment", "severity": "error", @@ -2949,7 +2949,7 @@ "code": -2, "column": 23, "concise_description": "`NoX8` is not assignable to `DefaultArg8`", - "description": "`NoX8` is not assignable to `DefaultArg8`\n `NoX8.__call__` has type `(self: NoX8) -> None`, which is not assignable to `(self: NoX8, x: int = 0) -> None`, the type of `DefaultArg8.__call__`", + "description": "`NoX8` is not assignable to `DefaultArg8`\n `NoX8.__call__` has type `() -> None`, which is not assignable to `(x: int = 0) -> None`, the type of `DefaultArg8.__call__`", "line": 237, "name": "bad-assignment", "severity": "error", @@ -2960,7 +2960,7 @@ "code": -2, "column": 25, "concise_description": "`NoX8` is not assignable to `NoDefaultArg8`", - "description": "`NoX8` is not assignable to `NoDefaultArg8`\n `NoX8.__call__` has type `(self: NoX8) -> None`, which is not assignable to `(self: NoX8, x: int) -> None`, the type of `NoDefaultArg8.__call__`", + "description": "`NoX8` is not assignable to `NoDefaultArg8`\n `NoX8.__call__` has type `() -> None`, which is not assignable to `(x: int) -> None`, the type of `NoDefaultArg8.__call__`", "line": 240, "name": "bad-assignment", "severity": "error", @@ -2971,7 +2971,7 @@ "code": -2, "column": 16, "concise_description": "`NoDefaultArg8` is not assignable to `NoX8`", - "description": "`NoDefaultArg8` is not assignable to `NoX8`\n `NoDefaultArg8.__call__` has type `(self: NoDefaultArg8, x: int) -> None`, which is not assignable to `(self: NoDefaultArg8) -> None`, the type of `NoX8.__call__`", + "description": "`NoDefaultArg8` is not assignable to `NoX8`\n `NoDefaultArg8.__call__` has type `(x: int) -> None`, which is not assignable to `() -> None`, the type of `NoX8.__call__`", "line": 243, "name": "bad-assignment", "severity": "error", @@ -2982,7 +2982,7 @@ "code": -2, "column": 21, "concise_description": "`Overloaded9` is not assignable to `FloatArg9`", - "description": "`Overloaded9` is not assignable to `FloatArg9`\n `Overloaded9.__call__` has type `Overload[\n (self: Overloaded9, x: int) -> int\n (self: Overloaded9, x: str) -> str\n]`, which is not assignable to `(self: Overloaded9, x: float) -> float`, the type of `FloatArg9.__call__`", + "description": "`Overloaded9` is not assignable to `FloatArg9`\n `Overloaded9.__call__` has type `Overload[\n (x: int) -> int\n (x: str) -> str\n]`, which is not assignable to `(x: float) -> float`, the type of `FloatArg9.__call__`", "line": 273, "name": "bad-assignment", "severity": "error", @@ -2993,7 +2993,7 @@ "code": -2, "column": 24, "concise_description": "`StrArg10` is not assignable to `Overloaded10`", - "description": "`StrArg10` is not assignable to `Overloaded10`\n `StrArg10.__call__` has type `(self: StrArg10, x: str) -> complex`, which is not assignable to `Overload[\n (self: StrArg10, x: int, y: str) -> float\n (self: StrArg10, x: str) -> complex\n]`, the type of `Overloaded10.__call__`", + "description": "`StrArg10` is not assignable to `Overloaded10`\n `StrArg10.__call__` has type `(x: str) -> complex`, which is not assignable to `Overload[\n (x: int, y: str) -> float\n (x: str) -> complex\n]`, the type of `Overloaded10.__call__`", "line": 297, "name": "bad-assignment", "severity": "error", @@ -3316,7 +3316,7 @@ "code": -2, "column": 9, "concise_description": "Class member `ChildC2.__init__` overrides parent class `ParentC` in an inconsistent manner", - "description": "Class member `ChildC2.__init__` overrides parent class `ParentC` in an inconsistent manner\n `ChildC2.__init__` has type `(self: ChildC2, x: str) -> None`, which is not assignable to `(self: ChildC2, x: int) -> None`, the type of `ParentC.__init__`\n Signature mismatch:\n expected: def __init__(self: ChildC2, x: int) -> None: ...\n ^^^ parameters\n found: def __init__(self: ChildC2, x: str) -> None: ...\n ^^^ parameters", + "description": "Class member `ChildC2.__init__` overrides parent class `ParentC` in an inconsistent manner\n `ChildC2.__init__` has type `(x: str) -> None`, which is not assignable to `(x: int) -> None`, the type of `ParentC.__init__`\n Signature mismatch:\n expected: def __init__(self: ChildC2, x: int) -> None: ...\n ^^^ parameters\n found: def __init__(self: ChildC2, x: str) -> None: ...\n ^^^ parameters", "line": 135, "name": "bad-override", "severity": "error", @@ -3994,7 +3994,7 @@ "code": -2, "column": 16, "concise_description": "`DC1` is not assignable to `Hashable`", - "description": "`DC1` is not assignable to `Hashable`\n `DC1.__hash__` has type `None`, which is not consistent with `(self: DC1) -> int` in `Hashable.__hash__` (the type of read-write attributes cannot be changed)", + "description": "`DC1` is not assignable to `Hashable`\n `DC1.__hash__` has type `None`, which is not consistent with `() -> int` in `Hashable.__hash__` (the type of read-write attributes cannot be changed)", "line": 18, "name": "bad-assignment", "severity": "error", @@ -4016,7 +4016,7 @@ "code": -2, "column": 16, "concise_description": "`DC3` is not assignable to `Hashable`", - "description": "`DC3` is not assignable to `Hashable`\n `DC3.__hash__` has type `None`, which is not consistent with `(self: DC3) -> int` in `Hashable.__hash__` (the type of read-write attributes cannot be changed)", + "description": "`DC3` is not assignable to `Hashable`\n `DC3.__hash__` has type `None`, which is not consistent with `() -> int` in `Hashable.__hash__` (the type of read-write attributes cannot be changed)", "line": 40, "name": "bad-assignment", "severity": "error", @@ -4113,8 +4113,8 @@ { "code": -2, "column": 9, - "concise_description": "`__post_init__` type `(self: DC1, x: int, y: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", - "description": "`__post_init__` type `(self: DC1, x: int, y: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", + "concise_description": "`__post_init__` type `(x: int, y: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", + "description": "`__post_init__` type `(x: int, y: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", "line": 19, "name": "bad-function-definition", "severity": "error", @@ -4146,8 +4146,8 @@ { "code": -2, "column": 9, - "concise_description": "`__post_init__` type `(self: DC2, x: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", - "description": "`__post_init__` type `(self: DC2, x: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", + "concise_description": "`__post_init__` type `(x: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", + "description": "`__post_init__` type `(x: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields", "line": 36, "name": "bad-function-definition", "severity": "error", @@ -7106,7 +7106,7 @@ "code": -2, "column": 19, "concise_description": "Argument `BadReturnType` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`", - "description": "Argument `BadReturnType` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`\n `BadReturnType.set_scale` has type `(self: BadReturnType, scale: float) -> int`, which is not assignable to `(self: BadReturnType, scale: float) -> BadReturnType`, the type of `ShapeProtocol.set_scale`", + "description": "Argument `BadReturnType` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`\n `BadReturnType.set_scale` has type `(scale: float) -> int`, which is not assignable to `(scale: float) -> BadReturnType`, the type of `ShapeProtocol.set_scale`", "line": 61, "name": "bad-argument-type", "severity": "error", @@ -7117,7 +7117,7 @@ "code": -2, "column": 19, "concise_description": "Argument `ReturnDifferentClass` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`", - "description": "Argument `ReturnDifferentClass` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`\n `ReturnDifferentClass.set_scale` has type `(self: ReturnDifferentClass, scale: float) -> ReturnConcreteShape`, which is not assignable to `(self: ReturnDifferentClass, scale: float) -> ReturnDifferentClass`, the type of `ShapeProtocol.set_scale`", + "description": "Argument `ReturnDifferentClass` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape`\n `ReturnDifferentClass.set_scale` has type `(scale: float) -> ReturnConcreteShape`, which is not assignable to `(scale: float) -> ReturnDifferentClass`, the type of `ShapeProtocol.set_scale`", "line": 64, "name": "bad-argument-type", "severity": "error", @@ -10305,7 +10305,7 @@ "code": -2, "column": 16, "concise_description": "`type[ConcreteA]` is not assignable to `ProtoA1`", - "description": "`type[ConcreteA]` is not assignable to `ProtoA1`\n `type[ConcreteA].method1` has type `(self: ConcreteA, x: int) -> int`, which is not assignable to `(self: type[ConcreteA], x: int) -> int`, the type of `ProtoA1.method1`", + "description": "`type[ConcreteA]` is not assignable to `ProtoA1`\n `type[ConcreteA].method1` has type `(self: ConcreteA, x: int) -> int`, which is not assignable to `(x: int) -> int`, the type of `ProtoA1.method1`", "line": 58, "name": "bad-assignment", "severity": "error", @@ -10316,7 +10316,7 @@ "code": -2, "column": 16, "concise_description": "`type[ConcreteB]` is not assignable to `ProtoB1`", - "description": "`type[ConcreteB]` is not assignable to `ProtoB1`\n `type[ConcreteB].prop1` has type `(self: ConcreteB) -> int`, which is not assignable to `(self: type[ConcreteB]) -> int`, the property getter for `ProtoB1.prop1`", + "description": "`type[ConcreteB]` is not assignable to `ProtoB1`\n `type[ConcreteB].prop1` has type `(self: ConcreteB) -> int`, which is not assignable to `() -> int`, the property getter for `ProtoB1.prop1`", "line": 74, "name": "bad-assignment", "severity": "error", @@ -10494,7 +10494,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete4_Bad1` is not assignable to `Template4`", - "description": "`Concrete4_Bad1` is not assignable to `Template4`\n `Concrete4_Bad1.val1` has type `(self: Concrete4_Bad1) -> Sequence[int]`, which is not assignable to `(self: Concrete4_Bad1) -> Sequence[float]`, the property getter for `Template4.val1`", + "description": "`Concrete4_Bad1` is not assignable to `Template4`\n `Concrete4_Bad1.val1` has type `() -> Sequence[int]`, which is not assignable to `() -> Sequence[float]`, the property getter for `Template4.val1`", "line": 218, "name": "bad-assignment", "severity": "error", @@ -10516,7 +10516,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete5_Bad1` is not assignable to `Template5`", - "description": "`Concrete5_Bad1` is not assignable to `Template5`\n `Concrete5_Bad1.method1` has type `(self: Concrete5_Bad1, a: Unknown, c: Unknown) -> int`, which is not assignable to `(self: Concrete5_Bad1, a: int, b: int) -> float`, the type of `Template5.method1`", + "description": "`Concrete5_Bad1` is not assignable to `Template5`\n `Concrete5_Bad1.method1` has type `(a: Unknown, c: Unknown) -> int`, which is not assignable to `(a: int, b: int) -> float`, the type of `Template5.method1`", "line": 285, "name": "bad-assignment", "severity": "error", @@ -10527,7 +10527,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete5_Bad2` is not assignable to `Template5`", - "description": "`Concrete5_Bad2` is not assignable to `Template5`\n `Concrete5_Bad2.method1` has type `(self: Concrete5_Bad2, a: int, c: int) -> int`, which is not assignable to `(self: Concrete5_Bad2, a: int, b: int) -> float`, the type of `Template5.method1`", + "description": "`Concrete5_Bad2` is not assignable to `Template5`\n `Concrete5_Bad2.method1` has type `(a: int, c: int) -> int`, which is not assignable to `(a: int, b: int) -> float`, the type of `Template5.method1`", "line": 286, "name": "bad-assignment", "severity": "error", @@ -10538,7 +10538,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete5_Bad3` is not assignable to `Template5`", - "description": "`Concrete5_Bad3` is not assignable to `Template5`\n `Concrete5_Bad3.method1` has type `(self: Concrete5_Bad3, *, a: int, b: int) -> float`, which is not assignable to `(self: Concrete5_Bad3, a: int, b: int) -> float`, the type of `Template5.method1`", + "description": "`Concrete5_Bad3` is not assignable to `Template5`\n `Concrete5_Bad3.method1` has type `(*, a: int, b: int) -> float`, which is not assignable to `(a: int, b: int) -> float`, the type of `Template5.method1`", "line": 287, "name": "bad-assignment", "severity": "error", @@ -10549,7 +10549,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete5_Bad4` is not assignable to `Template5`", - "description": "`Concrete5_Bad4` is not assignable to `Template5`\n `Concrete5_Bad4.method1` has type `(self: Concrete5_Bad4, a: int, b: int, /) -> float`, which is not assignable to `(self: Concrete5_Bad4, a: int, b: int) -> float`, the type of `Template5.method1`", + "description": "`Concrete5_Bad4` is not assignable to `Template5`\n `Concrete5_Bad4.method1` has type `(a: int, b: int, /) -> float`, which is not assignable to `(a: int, b: int) -> float`, the type of `Template5.method1`", "line": 288, "name": "bad-assignment", "severity": "error", @@ -10560,7 +10560,7 @@ "code": -2, "column": 22, "concise_description": "`Concrete5_Bad5` is not assignable to `Template5`", - "description": "`Concrete5_Bad5` is not assignable to `Template5`\n `Concrete5_Bad5.method1` has type `(self: Unknown, a: int, b: int) -> float`, which is not assignable to `(self: Concrete5_Bad5, a: int, b: int) -> float`, the type of `Template5.method1`", + "description": "`Concrete5_Bad5` is not assignable to `Template5`\n `Concrete5_Bad5.method1` has type `(self: Unknown, a: int, b: int) -> float`, which is not assignable to `(a: int, b: int) -> float`, the type of `Template5.method1`", "line": 289, "name": "bad-assignment", "severity": "error", @@ -10696,7 +10696,7 @@ "code": -2, "column": 24, "concise_description": "`Concrete1` is not assignable to `Proto1[int, str]`", - "description": "`Concrete1` is not assignable to `Proto1[int, str]`\n `Concrete1.method1` has type `(self: Concrete1, x: str) -> str`, which is not assignable to `(self: Concrete1, x: int) -> int`, the type of `Proto1.method1`", + "description": "`Concrete1` is not assignable to `Proto1[int, str]`\n `Concrete1.method1` has type `(x: str) -> str`, which is not assignable to `(x: int) -> int`, the type of `Proto1.method1`", "line": 40, "name": "bad-assignment", "severity": "error", @@ -10762,7 +10762,7 @@ "code": -2, "column": 25, "concise_description": "`ConcreteHasProperty2` is not assignable to `HasPropertyProto`", - "description": "`ConcreteHasProperty2` is not assignable to `HasPropertyProto`\n `ConcreteHasProperty2.m` has type `(self: ConcreteHasProperty2, item: int, callback: (int) -> str) -> str`, which is not assignable to `[T](self: ConcreteHasProperty2, item: T, callback: (T) -> str) -> str`, the type of `HasPropertyProto.m`", + "description": "`ConcreteHasProperty2` is not assignable to `HasPropertyProto`\n `ConcreteHasProperty2.m` has type `(item: int, callback: (int) -> str) -> str`, which is not assignable to `[T](item: T, callback: (T) -> str) -> str`, the type of `HasPropertyProto.m`", "line": 145, "name": "bad-assignment", "severity": "error", @@ -10773,7 +10773,7 @@ "code": -2, "column": 25, "concise_description": "`ConcreteHasProperty3` is not assignable to `HasPropertyProto`", - "description": "`ConcreteHasProperty3` is not assignable to `HasPropertyProto`\n Property getter for `ConcreteHasProperty3.f` has type `(self: ConcreteHasProperty3) -> int`, which is not assignable to `[T](self: T) -> T`, the property getter for `HasPropertyProto.f`", + "description": "`ConcreteHasProperty3` is not assignable to `HasPropertyProto`\n Property getter for `ConcreteHasProperty3.f` has type `() -> int`, which is not assignable to `[T]() -> T`, the property getter for `HasPropertyProto.f`", "line": 146, "name": "bad-assignment", "severity": "error", @@ -10784,7 +10784,7 @@ "code": -2, "column": 25, "concise_description": "`ConcreteHasProperty4` is not assignable to `HasPropertyProto`", - "description": "`ConcreteHasProperty4` is not assignable to `HasPropertyProto`\n `ConcreteHasProperty4.m` has type `(self: ConcreteHasProperty4, item: str, callback: (int) -> str) -> str`, which is not assignable to `[T](self: ConcreteHasProperty4, item: T, callback: (T) -> str) -> str`, the type of `HasPropertyProto.m`", + "description": "`ConcreteHasProperty4` is not assignable to `HasPropertyProto`\n `ConcreteHasProperty4.m` has type `(item: str, callback: (int) -> str) -> str`, which is not assignable to `[T](item: T, callback: (T) -> str) -> str`, the type of `HasPropertyProto.m`", "line": 147, "name": "bad-assignment", "severity": "error", @@ -10876,7 +10876,7 @@ "code": -2, "column": 18, "concise_description": "`Module[_protocols_modules2]` is not assignable to `Reporter2`", - "description": "`Module[_protocols_modules2]` is not assignable to `Reporter2`\n `Module[_protocols_modules2].on_error` has type `(x: int) -> None`, which is not assignable to `(self: Module[_protocols_modules2], x: int) -> int`, the type of `Reporter2.on_error`", + "description": "`Module[_protocols_modules2]` is not assignable to `Reporter2`\n `Module[_protocols_modules2].on_error` has type `(x: int) -> None`, which is not assignable to `(x: int) -> int`, the type of `Reporter2.on_error`", "line": 48, "name": "bad-assignment", "severity": "error", @@ -10934,7 +10934,7 @@ "code": -2, "column": 33, "concise_description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`", - "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(self: Concrete3A, a: str) -> None`, which is not assignable to `(self: Concrete3A, a: int) -> int`, the type of `Proto3.method1`", + "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(a: str) -> None`, which is not assignable to `(a: int) -> int`, the type of `Proto3.method1`", "line": 88, "name": "unsafe-overlap", "severity": "error", @@ -10945,7 +10945,7 @@ "code": -2, "column": 33, "concise_description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B`", - "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B`\n Attribute `method1` has incompatible types: `Concrete3B.method1` has type `int`, which is not consistent with `(self: Concrete3B, a: int) -> int` in `Proto3.method1` (the type of read-write attributes cannot be changed)", + "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B`\n Attribute `method1` has incompatible types: `Concrete3B.method1` has type `int`, which is not consistent with `(a: int) -> int` in `Proto3.method1` (the type of read-write attributes cannot be changed)", "line": 91, "name": "unsafe-overlap", "severity": "error", @@ -10956,7 +10956,7 @@ "code": -2, "column": 33, "concise_description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B`", - "description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B`\n Attribute `method1` has incompatible types: `Concrete3B.method1` has type `int`, which is not consistent with `(self: Concrete3B) -> int` in `NonDataProtocol.method1` (the type of read-write attributes cannot be changed)", + "description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B`\n Attribute `method1` has incompatible types: `Concrete3B.method1` has type `int`, which is not consistent with `() -> int` in `NonDataProtocol.method1` (the type of read-write attributes cannot be changed)", "line": 91, "name": "unsafe-overlap", "severity": "error", @@ -10967,7 +10967,7 @@ "code": -2, "column": 31, "concise_description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`", - "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(self: Concrete3A, a: str) -> None`, which is not assignable to `(self: Concrete3A, a: int) -> int`, the type of `Proto3.method1`", + "description": "Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(a: str) -> None`, which is not assignable to `(a: int) -> int`, the type of `Proto3.method1`", "line": 94, "name": "unsafe-overlap", "severity": "error", @@ -10978,7 +10978,7 @@ "code": -2, "column": 31, "concise_description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A`", - "description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(self: Concrete3A, a: str) -> None`, which is not assignable to `(self: Concrete3A) -> int`, the type of `NonDataProtocol.method1`", + "description": "Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A`\n Attribute `method1` has incompatible types: `Concrete3A.method1` has type `(a: str) -> None`, which is not assignable to `() -> int`, the type of `NonDataProtocol.method1`", "line": 94, "name": "unsafe-overlap", "severity": "error", @@ -11025,7 +11025,7 @@ "code": -2, "column": 30, "concise_description": "`Proto5[int]` is not assignable to `Proto4[int, float]`", - "description": "`Proto5[int]` is not assignable to `Proto4[int, float]`\n `Proto5[int].method1` has type `(self: Proto5[int], a: int, b: int) -> tuple[int, int]`, which is not assignable to `(self: Proto5[int], a: int, b: float) -> tuple[int, float]`, the type of `Proto4.method1`", + "description": "`Proto5[int]` is not assignable to `Proto4[int, float]`\n `Proto5[int].method1` has type `(a: int, b: int) -> tuple[int, int]`, which is not assignable to `(a: int, b: float) -> tuple[int, float]`, the type of `Proto4.method1`", "line": 79, "name": "bad-assignment", "severity": "error", @@ -11036,7 +11036,7 @@ "code": -2, "column": 25, "concise_description": "`Proto4[int, int]` is not assignable to `Proto5[float]`", - "description": "`Proto4[int, int]` is not assignable to `Proto5[float]`\n `Proto4[int, int].method1` has type `(self: Proto4[int, int], a: int, b: int) -> tuple[int, int]`, which is not assignable to `(self: Proto4[int, int], a: float, b: float) -> tuple[float, float]`, the type of `Proto5.method1`", + "description": "`Proto4[int, int]` is not assignable to `Proto5[float]`\n `Proto4[int, int].method1` has type `(a: int, b: int) -> tuple[int, int]`, which is not assignable to `(a: float, b: float) -> tuple[float, float]`, the type of `Proto5.method1`", "line": 80, "name": "bad-assignment", "severity": "error", @@ -11047,7 +11047,7 @@ "code": -2, "column": 30, "concise_description": "`Proto6[float, float]` is not assignable to `Proto7[int, float]`", - "description": "`Proto6[float, float]` is not assignable to `Proto7[int, float]`\n `Proto6[float, float].method1` has type `(self: Proto6[float, float], a: float) -> Sequence[float]`, which is not assignable to `(self: Proto6[float, float], a: float) -> Sequence[int]`, the type of `Proto7.method1`", + "description": "`Proto6[float, float]` is not assignable to `Proto7[int, float]`\n `Proto6[float, float].method1` has type `(a: float) -> Sequence[float]`, which is not assignable to `(a: float) -> Sequence[int]`, the type of `Proto7.method1`", "line": 102, "name": "bad-assignment", "severity": "error", @@ -11058,7 +11058,7 @@ "code": -2, "column": 33, "concise_description": "`Proto6[float, float]` is not assignable to `Proto7[float, object]`", - "description": "`Proto6[float, float]` is not assignable to `Proto7[float, object]`\n `Proto6[float, float].method1` has type `(self: Proto6[float, float], a: float) -> Sequence[float]`, which is not assignable to `(self: Proto6[float, float], a: object) -> Sequence[float]`, the type of `Proto7.method1`", + "description": "`Proto6[float, float]` is not assignable to `Proto7[float, object]`\n `Proto6[float, float].method1` has type `(a: float) -> Sequence[float]`, which is not assignable to `(a: object) -> Sequence[float]`, the type of `Proto7.method1`", "line": 103, "name": "bad-assignment", "severity": "error", diff --git a/crates/pyrefly_types/src/display.rs b/crates/pyrefly_types/src/display.rs index b0ba4568da..245697f755 100644 --- a/crates/pyrefly_types/src/display.rs +++ b/crates/pyrefly_types/src/display.rs @@ -1135,7 +1135,13 @@ impl<'a> TypeDisplayContext<'a> { LspDisplayMode::Hover | LspDisplayMode::SignatureHelp => { self.fmt_helper_generic(&func.clone().as_type(), false, output) } - _ => self.fmt_helper_generic(&func.clone().as_type(), is_toplevel, output), + // Binding has already consumed the receiver, so showing it would + // misreport what the value can be called with, and would make a bound + // method indistinguishable from the unbound one it came from. + _ => { + let displayed = func.strip_receiver().unwrap_or_else(|| func.clone()); + self.fmt_helper_generic(&displayed.as_type(), is_toplevel, output) + } } } Type::Never(NeverStyle::NoReturn) => { @@ -2681,7 +2687,7 @@ pub mod tests { let mut ctx = TypeDisplayContext::new(&[&bound_method]); assert_eq!( ctx.display(&bound_method).to_string(), - "(self: Any, x: Any, y: Any) -> None" + "(x: Any, y: Any) -> None" ); ctx.set_lsp_display_mode(LspDisplayMode::Hover); assert_eq!( @@ -2710,7 +2716,7 @@ pub mod tests { let mut ctx = TypeDisplayContext::new(&[&bound_method]); assert_eq!( ctx.display(&bound_method).to_string(), - "[T](self: Any, x: Any, y: Any) -> None" + "[T](x: Any, y: Any) -> None" ); ctx.set_lsp_display_mode(LspDisplayMode::Hover); assert_eq!( @@ -2739,7 +2745,7 @@ pub mod tests { let mut ctx = TypeDisplayContext::new(&[&method]); assert_eq!( ctx.display(&method).to_string(), - "[T, **P, R](self: Any, x: Any, y: Any) -> None" + "[T, **P, R](x: Any, y: Any) -> None" ); ctx.set_lsp_display_mode(LspDisplayMode::Hover); assert_eq!( @@ -2763,7 +2769,7 @@ pub mod tests { let mut ctx = TypeDisplayContext::new(&[&method]); assert_eq!( ctx.display(&method).to_string(), - "[T, *Ts, R](self: Any, x: Any, y: Any) -> None" + "[T, *Ts, R](x: Any, y: Any) -> None" ); ctx.set_lsp_display_mode(LspDisplayMode::Hover); assert_eq!( @@ -2868,7 +2874,7 @@ def overloaded_func[T]( let ctx = TypeDisplayContext::new(&[&bound_method_overload]); assert_eq!( ctx.display(&bound_method_overload).to_string(), - "Overload[\n (x: Any) -> None\n [T](x: Any, y: Any) -> None\n]" + "Overload[\n () -> None\n [T](y: Any) -> None\n]" ); // Test compact display mode as non-toplevel type (non-hover) @@ -2876,7 +2882,7 @@ def overloaded_func[T]( let ctx = TypeDisplayContext::new(&[&type_form_of_bound_method_overload]); assert_eq!( ctx.display(&type_form_of_bound_method_overload).to_string(), - "type[Overload[(x: Any) -> None, [T](x: Any, y: Any) -> None]]" + "type[Overload[() -> None, [T](y: Any) -> None]]" ); // Test hover display mode (with @overload decorators) diff --git a/crates/pyrefly_types/src/types.rs b/crates/pyrefly_types/src/types.rs index dd289f3438..503eab9fa6 100644 --- a/crates/pyrefly_types/src/types.rs +++ b/crates/pyrefly_types/src/types.rs @@ -454,6 +454,67 @@ impl BoundMethodType { } } + /// The signature callers see, with the receiver parameter that binding already + /// consumed removed. Returns `None` when no parameter can be stripped, which + /// happens for signatures like `(...) -> T` that have no leading positional param. + /// + /// This is a display-only view: `bind_bound_method_type` in the solver performs the + /// same strip, and additionally instantiates type parameters against the receiver. + pub fn strip_receiver(&self) -> Option { + match self { + Self::Function(func) => func.signature.strip_first_param().map(|signature| { + Self::Function(Function { + signature, + metadata: func.metadata.clone(), + }) + }), + Self::Forall(forall) => forall.body.signature.strip_first_param().map(|signature| { + Self::Forall(Forall { + tparams: forall.tparams.clone(), + body: Function { + signature, + metadata: forall.body.metadata.clone(), + }, + }) + }), + Self::Overload(overload) => overload + .signatures + .try_mapped_ref(|x| match x { + OverloadType::Function(f) => f + .signature + .strip_first_param() + .map(|signature| { + OverloadType::Function(Function { + signature, + metadata: f.metadata.clone(), + }) + }) + .ok_or(()), + OverloadType::Forall(forall) => forall + .body + .signature + .strip_first_param() + .map(|signature| { + OverloadType::Forall(Forall { + tparams: forall.tparams.clone(), + body: Function { + signature, + metadata: forall.body.metadata.clone(), + }, + }) + }) + .ok_or(()), + }) + .ok() + .map(|signatures| { + Self::Overload(Overload { + signatures, + metadata: overload.metadata.clone(), + }) + }), + } + } + pub fn subst_self_type_mut(&mut self, replacement: &Type) { match self { Self::Function(func) => func.signature.subst_self_type_mut(replacement), diff --git a/pyrefly/lib/error/signature_diff.rs b/pyrefly/lib/error/signature_diff.rs index 6113dea731..0898d099ac 100644 --- a/pyrefly/lib/error/signature_diff.rs +++ b/pyrefly/lib/error/signature_diff.rs @@ -265,7 +265,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B) -> None`, which is not assignable to `(self: B, a: int, b: int, c: int) -> Unknown`, the type of `A.foo` + `B.foo` has type `() -> None`, which is not assignable to `(a: int, b: int, c: int) -> Unknown`, the type of `A.foo` Signature mismatch: expected: def foo(self: B, a: int, b: int, c: int) -> Unknown: ... ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ return type @@ -294,7 +294,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B, x: int, y: str) -> None`, which is not assignable to `(self: B) -> None`, the type of `A.foo` + `B.foo` has type `(x: int, y: str) -> None`, which is not assignable to `() -> None`, the type of `A.foo` Signature mismatch: expected: def foo(self: B) -> None: ... ^ parameters @@ -319,7 +319,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B, x: str) -> None`, which is not assignable to `(self: B, x: int) -> None`, the type of `A.foo` + `B.foo` has type `(x: str) -> None`, which is not assignable to `(x: int) -> None`, the type of `A.foo` Signature mismatch: expected: def foo(self: B, x: int) -> None: ... ^^^ parameters @@ -344,7 +344,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B, x: int) -> str`, which is not assignable to `(self: B, x: int) -> int`, the type of `A.foo` + `B.foo` has type `(x: int) -> str`, which is not assignable to `(x: int) -> int`, the type of `A.foo` Signature mismatch: expected: def foo(self: B, x: int) -> int: ... ^^^ return type @@ -377,9 +377,9 @@ class B(A): assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); // Overloads have multiple signatures, so no signature diff is shown. let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B, x: float) -> float`, which is not assignable to `Overload[ - (self: B, x: int) -> int - (self: B, x: str) -> str + `B.foo` has type `(x: float) -> float`, which is not assignable to `Overload[ + (x: int) -> int + (x: str) -> str ]`, the type of `A.foo`"#; assert_eq!(messages[0], expected); } @@ -401,7 +401,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: B, x: str) -> str`, which is not assignable to `(self: B, x: int) -> int`, the type of `A.foo` + `B.foo` has type `(x: str) -> str`, which is not assignable to `(x: int) -> int`, the type of `A.foo` Signature mismatch: expected: def foo(self: B, x: int) -> int: ... ^^^ ^^^ return type @@ -431,7 +431,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.foo` overrides parent class `A` in an inconsistent manner - `B.foo` has type `(self: Unknown) -> None`, which is not consistent with `(self: B, x: int) -> int` in `A.foo` (the type of read-write attributes cannot be changed) + `B.foo` has type `(self: Unknown) -> None`, which is not consistent with `(x: int) -> int` in `A.foo` (the type of read-write attributes cannot be changed) Signature mismatch: expected: def foo(self: B, x: int) -> int: ... ^^^^^^^^^ ^^^ return type @@ -463,7 +463,7 @@ class B(A): ); assert_eq!(messages.len(), 1, "Expected one error, got {messages:?}"); let expected = r#"Class member `B.method` overrides parent class `A` in an inconsistent manner - `B.method` has type `(self: Unknown) -> None`, which is not assignable to `(self: B, x: int) -> int`, the type of `A.method` + `B.method` has type `() -> None`, which is not assignable to `(x: int) -> int`, the type of `A.method` Signature mismatch: expected: def method(self: B, x: int) -> int: ... ^^^^^^^^^ ^^^ return type diff --git a/pyrefly/lib/test/attributes.rs b/pyrefly/lib/test/attributes.rs index c5c58dcb3c..a49c41e932 100644 --- a/pyrefly/lib/test/attributes.rs +++ b/pyrefly/lib/test/attributes.rs @@ -615,7 +615,7 @@ def f2(c: Callable[[C, int], None]): f1(C.f) # E: Argument `(self: C, x: int) -> None` is not assignable to parameter `c` with type `(int) -> None` f1(C().f) f2(C.f) -f2(C().f) # E: Argument `(self: C, x: int) -> None` is not assignable to parameter `c` with type `(C, int) -> None` +f2(C().f) # E: Argument `(x: int) -> None` is not assignable to parameter `c` with type `(C, int) -> None` "#, ); @@ -1129,7 +1129,7 @@ def test(o: D): reveal_type(o.f) # E: [T](x: T) -> T assert_type(o.f(1), int) - reveal_type(o.g) # E: [U](self: C, x: U) -> U + reveal_type(o.g) # E: [U](x: U) -> U assert_type(o.g(1), int) "#, ); @@ -2286,7 +2286,7 @@ testcase!( r#" from typing import Never, assert_type, reveal_type def f() -> type[Never]: ... -reveal_type(f().mro) # E: (self: type) -> list[type[Any]] +reveal_type(f().mro) # E: () -> list[type[Any]] assert_type(f().wut, Never) "#, ); diff --git a/pyrefly/lib/test/callable_residuals.rs b/pyrefly/lib/test/callable_residuals.rs index 3940ea6565..e84304a282 100644 --- a/pyrefly/lib/test/callable_residuals.rs +++ b/pyrefly/lib/test/callable_residuals.rs @@ -322,7 +322,7 @@ class Wrapper[**P, R]: def f[S](x: S) -> S: ... wrapper = Wrapper(f) reveal_type(wrapper.fn) # E: revealed type: [R](x: R) -> R -reveal_type(wrapper.__call__) # E: [R](self: Wrapper[[x: R], R], x: R) -> R +reveal_type(wrapper.__call__) # E: [R](x: R) -> R assert_type(wrapper(1), int) "#, ); @@ -345,7 +345,7 @@ def wrap[**P, R](f: Callable[P, R]) -> Wrapper[P, R]: def f[S](x: S) -> S: ... wrapper = wrap(f) reveal_type(wrapper.fn) # E: revealed type: [R](x: R) -> R -reveal_type(wrapper.__call__) # E: [R](self: Wrapper[[x: R], R], x: R) -> R +reveal_type(wrapper.__call__) # E: [R](x: R) -> R assert_type(wrapper(1), int) "#, ); @@ -363,7 +363,7 @@ class Wrapper[**P, R]: def f[S](x: S) -> S: ... wrapper = Wrapper(f) reveal_type(wrapper) # E: revealed type: Wrapper[[x: GenericResidual@R], GenericResidual@R] -reveal_type(wrapper.__call__) # E: [R](self: Wrapper[[x: R], R], x: R) -> R +reveal_type(wrapper.__call__) # E: [R](x: R) -> R "#, ); @@ -451,7 +451,7 @@ class Wrapper[**P, R]: ctor = identity(Wrapper) reveal_type(ctor) # E: revealed type: [**P, R](fn: (ParamSpec(P)) -> R) -> Wrapper[P, R] identity2 = ctor(identity) -reveal_type(identity2.__call__) # E: revealed type: [**P, R](self: Wrapper[[x: (ParamSpec(P)) -> R], (ParamSpec(P)) -> R], x: (ParamSpec(P)) -> R) -> (ParamSpec(P)) -> R +reveal_type(identity2.__call__) # E: revealed type: [**P, R](x: (ParamSpec(P)) -> R) -> (ParamSpec(P)) -> R "#, ); diff --git a/pyrefly/lib/test/class_overrides.rs b/pyrefly/lib/test/class_overrides.rs index a819cd83c5..bd45a18a85 100644 --- a/pyrefly/lib/test/class_overrides.rs +++ b/pyrefly/lib/test/class_overrides.rs @@ -932,7 +932,7 @@ class A: def f(self, x: TA1): pass class B(A): - def f(self, x: TA2): # E: `B.f` has type `(self: B, x: TA2) -> None`, which is not assignable to `(self: B, x: TA1) -> None`, the type of `A.f` + def f(self, x: TA2): # E: `B.f` has type `(x: TA2) -> None`, which is not assignable to `(x: TA1) -> None`, the type of `A.f` pass "#, ); @@ -2030,7 +2030,7 @@ class Base: pass class ChildNarrowed(Base): - p: B # E: `ChildNarrowed.p` has type `B`, which is not assignable from `(self: ChildNarrowed, value: A) -> None`, the property setter for `Base.p` + p: B # E: `ChildNarrowed.p` has type `B`, which is not assignable from `(value: A) -> None`, the property setter for `Base.p` class ChildSuppressed(Base): p: B # pyrefly: ignore[bad-override-mutable-attribute] @@ -2046,7 +2046,7 @@ class ChildWidened(Base): # Property-to-property override with narrowed setter. class ChildPropertyNarrowedSetter(Base): @property - def p(self) -> A: # E: The property setter for `ChildPropertyNarrowedSetter.p` has type `(self: ChildPropertyNarrowedSetter, value: B) -> None`, which is not assignable from `(self: ChildPropertyNarrowedSetter, value: A) -> None`, the property setter for `Base.p` + def p(self) -> A: # E: The property setter for `ChildPropertyNarrowedSetter.p` has type `(value: B) -> None`, which is not assignable from `(value: A) -> None`, the property setter for `Base.p` return A() @p.setter def p(self, value: B) -> None: diff --git a/pyrefly/lib/test/class_super.rs b/pyrefly/lib/test/class_super.rs index b3cf3605e7..ee2f4d106d 100644 --- a/pyrefly/lib/test/class_super.rs +++ b/pyrefly/lib/test/class_super.rs @@ -196,7 +196,7 @@ class Parent: class Child(Parent): def __init__(self) -> None: - self.meth2 = super().meth1 # E: `(self: type[Self@Child]) -> int` is not assignable to attribute `meth2` with type `(self: type[Self@Child]) -> str` + self.meth2 = super().meth1 # E: `() -> int` is not assignable to attribute `meth2` with type `() -> str` # At runtime, this is a call to the inherited `Parent.meth2` classmethod. # We don't have a good way of modeling this, so we treat this as an (illegal) class access of the diff --git a/pyrefly/lib/test/dataclasses.rs b/pyrefly/lib/test/dataclasses.rs index 693791951e..479a232444 100644 --- a/pyrefly/lib/test/dataclasses.rs +++ b/pyrefly/lib/test/dataclasses.rs @@ -2188,7 +2188,7 @@ class Bad1: x: int y: InitVar[str] z: InitVar[bytes] - def __post_init__(self, y: bytes, z: str): ... # E: `__post_init__` type `(self: Bad1, y: bytes, z: str) -> None` is not assignable to expected type `(y: str, z: bytes) -> object` generated from the dataclass's `InitVar` fields + def __post_init__(self, y: bytes, z: str): ... # E: `__post_init__` type `(y: bytes, z: str) -> None` is not assignable to expected type `(y: str, z: bytes) -> object` generated from the dataclass's `InitVar` fields @dataclass class Bad2: x: int diff --git a/pyrefly/lib/test/descriptors.rs b/pyrefly/lib/test/descriptors.rs index db46fcd8f6..cb2aa29e0a 100644 --- a/pyrefly/lib/test/descriptors.rs +++ b/pyrefly/lib/test/descriptors.rs @@ -54,8 +54,8 @@ class C: def foo(cls) -> int: return 42 def f(c: C): - reveal_type(C.foo) # E: revealed type: (cls: type[C]) -> int - reveal_type(c.foo) # E: revealed type: (cls: type[C]) -> int + reveal_type(C.foo) # E: revealed type: () -> int + reveal_type(c.foo) # E: revealed type: () -> int "#, ); diff --git a/pyrefly/lib/test/named_tuple.rs b/pyrefly/lib/test/named_tuple.rs index 5dc7489e62..71504df229 100644 --- a/pyrefly/lib/test/named_tuple.rs +++ b/pyrefly/lib/test/named_tuple.rs @@ -346,8 +346,8 @@ class Pair2[T](NamedTuple): y: T def test(p: Pair, p2: Pair2[bytes]): - reveal_type(p.__iter__) # E: (self: Pair) -> Iterator[int | str] - reveal_type(p2.__iter__) # E: (self: Pair2[bytes]) -> Iterator[bytes | int] + reveal_type(p.__iter__) # E: () -> Iterator[int | str] + reveal_type(p2.__iter__) # E: () -> Iterator[bytes | int] "#, ); diff --git a/pyrefly/lib/test/simple.rs b/pyrefly/lib/test/simple.rs index bbebb44603..78907e8848 100644 --- a/pyrefly/lib/test/simple.rs +++ b/pyrefly/lib/test/simple.rs @@ -463,7 +463,7 @@ class Asset(TestABC): class PensionAsset(Asset): @classmethod - def _money_desc(cls): # E: `PensionAsset._money_desc` has type `(cls: type[PensionAsset]) -> Literal['90岁累计可领(元)']`, which is not assignable to `(cls: type[PensionAsset]) -> Literal['累计可领(元)']`, the type of `Asset._money_desc` + def _money_desc(cls): # E: `PensionAsset._money_desc` has type `() -> Literal['90岁累计可领(元)']`, which is not assignable to `() -> Literal['累计可领(元)']`, the type of `Asset._money_desc` return '90岁累计可领(元)' "#, ); diff --git a/test/sarif/diagnostics.expected.sarif b/test/sarif/diagnostics.expected.sarif index 5632ef5d2d..f4c236a71c 100644 --- a/test/sarif/diagnostics.expected.sarif +++ b/test/sarif/diagnostics.expected.sarif @@ -138,7 +138,7 @@ "ruleIndex": 0, "level": "error", "message": { - "text": "`Mismatched` is not assignable to `Comparable`\n`Mismatched.compare` has type `(self: Mismatched) -> str`, which is not assignable to `(self: Mismatched) -> int`, the type of `Comparable.compare`" + "text": "`Mismatched` is not assignable to `Comparable`\n`Mismatched.compare` has type `() -> str`, which is not assignable to `() -> int`, the type of `Comparable.compare`" }, "locations": [ {