[ty] Uniformly use "not supported" in diagnostics (#21916)

This commit is contained in:
Luca Chiodini 2025-12-11 16:03:55 +01:00 committed by GitHub
parent c9155d5e72
commit 5a9d6a91ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 122 additions and 122 deletions

View File

@ -44,7 +44,7 @@ class C:
return 42 return 42
x = C() x = C()
# error: [unsupported-operator] "Operator `-=` is unsupported between objects of type `C` and `Literal[1]`" # error: [unsupported-operator] "Operator `-=` is not supported between objects of type `C` and `Literal[1]`"
x -= 1 x -= 1
reveal_type(x) # revealed: int reveal_type(x) # revealed: int
@ -79,7 +79,7 @@ def _(flag: bool):
f = Foo() f = Foo()
# error: [unsupported-operator] "Operator `+=` is unsupported between objects of type `Foo` and `Literal["Hello, world!"]`" # error: [unsupported-operator] "Operator `+=` is not supported between objects of type `Foo` and `Literal["Hello, world!"]`"
f += "Hello, world!" f += "Hello, world!"
reveal_type(f) # revealed: int | Unknown reveal_type(f) # revealed: int | Unknown

View File

@ -27,7 +27,7 @@ python-version = "3.9"
class A: ... class A: ...
class B: ... class B: ...
# error: "Operator `|` is unsupported between objects of type `<class 'A'>` and `<class 'B'>`" # error: "Operator `|` is not supported between objects of type `<class 'A'>` and `<class 'B'>`"
reveal_type(A | B) # revealed: Unknown reveal_type(A | B) # revealed: Unknown
``` ```

View File

@ -79,59 +79,59 @@ reveal_type(Sub() & Sub()) # revealed: Literal["&"]
reveal_type(Sub() // Sub()) # revealed: Literal["//"] reveal_type(Sub() // Sub()) # revealed: Literal["//"]
# No does not implement any of the dunder methods. # No does not implement any of the dunder methods.
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `No` and `No`"
reveal_type(No() + No()) # revealed: Unknown reveal_type(No() + No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `-` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `-` is not supported between objects of type `No` and `No`"
reveal_type(No() - No()) # revealed: Unknown reveal_type(No() - No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `*` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `*` is not supported between objects of type `No` and `No`"
reveal_type(No() * No()) # revealed: Unknown reveal_type(No() * No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `@` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `@` is not supported between objects of type `No` and `No`"
reveal_type(No() @ No()) # revealed: Unknown reveal_type(No() @ No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `/` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `/` is not supported between objects of type `No` and `No`"
reveal_type(No() / No()) # revealed: Unknown reveal_type(No() / No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `%` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `%` is not supported between objects of type `No` and `No`"
reveal_type(No() % No()) # revealed: Unknown reveal_type(No() % No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `**` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `**` is not supported between objects of type `No` and `No`"
reveal_type(No() ** No()) # revealed: Unknown reveal_type(No() ** No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `<<` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `<<` is not supported between objects of type `No` and `No`"
reveal_type(No() << No()) # revealed: Unknown reveal_type(No() << No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `>>` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `>>` is not supported between objects of type `No` and `No`"
reveal_type(No() >> No()) # revealed: Unknown reveal_type(No() >> No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `|` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `|` is not supported between objects of type `No` and `No`"
reveal_type(No() | No()) # revealed: Unknown reveal_type(No() | No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `^` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `^` is not supported between objects of type `No` and `No`"
reveal_type(No() ^ No()) # revealed: Unknown reveal_type(No() ^ No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `&` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `&` is not supported between objects of type `No` and `No`"
reveal_type(No() & No()) # revealed: Unknown reveal_type(No() & No()) # revealed: Unknown
# error: [unsupported-operator] "Operator `//` is unsupported between objects of type `No` and `No`" # error: [unsupported-operator] "Operator `//` is not supported between objects of type `No` and `No`"
reveal_type(No() // No()) # revealed: Unknown reveal_type(No() // No()) # revealed: Unknown
# Yes does not implement any of the reflected dunder methods. # Yes does not implement any of the reflected dunder methods.
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `No` and `Yes`"
reveal_type(No() + Yes()) # revealed: Unknown reveal_type(No() + Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `-` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `-` is not supported between objects of type `No` and `Yes`"
reveal_type(No() - Yes()) # revealed: Unknown reveal_type(No() - Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `*` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `*` is not supported between objects of type `No` and `Yes`"
reveal_type(No() * Yes()) # revealed: Unknown reveal_type(No() * Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `@` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `@` is not supported between objects of type `No` and `Yes`"
reveal_type(No() @ Yes()) # revealed: Unknown reveal_type(No() @ Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `/` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `/` is not supported between objects of type `No` and `Yes`"
reveal_type(No() / Yes()) # revealed: Unknown reveal_type(No() / Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `%` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `%` is not supported between objects of type `No` and `Yes`"
reveal_type(No() % Yes()) # revealed: Unknown reveal_type(No() % Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `**` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `**` is not supported between objects of type `No` and `Yes`"
reveal_type(No() ** Yes()) # revealed: Unknown reveal_type(No() ** Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `<<` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `<<` is not supported between objects of type `No` and `Yes`"
reveal_type(No() << Yes()) # revealed: Unknown reveal_type(No() << Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `>>` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `>>` is not supported between objects of type `No` and `Yes`"
reveal_type(No() >> Yes()) # revealed: Unknown reveal_type(No() >> Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `|` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `|` is not supported between objects of type `No` and `Yes`"
reveal_type(No() | Yes()) # revealed: Unknown reveal_type(No() | Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `^` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `^` is not supported between objects of type `No` and `Yes`"
reveal_type(No() ^ Yes()) # revealed: Unknown reveal_type(No() ^ Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `&` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `&` is not supported between objects of type `No` and `Yes`"
reveal_type(No() & Yes()) # revealed: Unknown reveal_type(No() & Yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `//` is unsupported between objects of type `No` and `Yes`" # error: [unsupported-operator] "Operator `//` is not supported between objects of type `No` and `Yes`"
reveal_type(No() // Yes()) # revealed: Unknown reveal_type(No() // Yes()) # revealed: Unknown
``` ```
@ -307,11 +307,11 @@ class Yes:
class Sub(Yes): ... class Sub(Yes): ...
class No: ... class No: ...
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `<class 'Yes'>` and `<class 'Yes'>`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `<class 'Yes'>` and `<class 'Yes'>`"
reveal_type(Yes + Yes) # revealed: Unknown reveal_type(Yes + Yes) # revealed: Unknown
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `<class 'Sub'>` and `<class 'Sub'>`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `<class 'Sub'>` and `<class 'Sub'>`"
reveal_type(Sub + Sub) # revealed: Unknown reveal_type(Sub + Sub) # revealed: Unknown
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `<class 'No'>` and `<class 'No'>`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `<class 'No'>` and `<class 'No'>`"
reveal_type(No + No) # revealed: Unknown reveal_type(No + No) # revealed: Unknown
``` ```
@ -336,11 +336,11 @@ def sub() -> type[Sub]:
def no() -> type[No]: def no() -> type[No]:
return No return No
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `type[Yes]` and `type[Yes]`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `type[Yes]` and `type[Yes]`"
reveal_type(yes() + yes()) # revealed: Unknown reveal_type(yes() + yes()) # revealed: Unknown
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `type[Sub]` and `type[Sub]`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `type[Sub]` and `type[Sub]`"
reveal_type(sub() + sub()) # revealed: Unknown reveal_type(sub() + sub()) # revealed: Unknown
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `type[No]` and `type[No]`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `type[No]` and `type[No]`"
reveal_type(no() + no()) # revealed: Unknown reveal_type(no() + no()) # revealed: Unknown
``` ```
@ -350,30 +350,30 @@ reveal_type(no() + no()) # revealed: Unknown
def f(): def f():
pass pass
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f + f) # revealed: Unknown reveal_type(f + f) # revealed: Unknown
# error: [unsupported-operator] "Operator `-` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `-` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f - f) # revealed: Unknown reveal_type(f - f) # revealed: Unknown
# error: [unsupported-operator] "Operator `*` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `*` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f * f) # revealed: Unknown reveal_type(f * f) # revealed: Unknown
# error: [unsupported-operator] "Operator `@` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `@` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f @ f) # revealed: Unknown reveal_type(f @ f) # revealed: Unknown
# error: [unsupported-operator] "Operator `/` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `/` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f / f) # revealed: Unknown reveal_type(f / f) # revealed: Unknown
# error: [unsupported-operator] "Operator `%` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `%` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f % f) # revealed: Unknown reveal_type(f % f) # revealed: Unknown
# error: [unsupported-operator] "Operator `**` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `**` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f**f) # revealed: Unknown reveal_type(f**f) # revealed: Unknown
# error: [unsupported-operator] "Operator `<<` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `<<` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f << f) # revealed: Unknown reveal_type(f << f) # revealed: Unknown
# error: [unsupported-operator] "Operator `>>` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `>>` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f >> f) # revealed: Unknown reveal_type(f >> f) # revealed: Unknown
# error: [unsupported-operator] "Operator `|` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `|` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f | f) # revealed: Unknown reveal_type(f | f) # revealed: Unknown
# error: [unsupported-operator] "Operator `^` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `^` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f ^ f) # revealed: Unknown reveal_type(f ^ f) # revealed: Unknown
# error: [unsupported-operator] "Operator `&` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `&` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f & f) # revealed: Unknown reveal_type(f & f) # revealed: Unknown
# error: [unsupported-operator] "Operator `//` is unsupported between objects of type `def f() -> Unknown` and `def f() -> Unknown`" # error: [unsupported-operator] "Operator `//` is not supported between objects of type `def f() -> Unknown` and `def f() -> Unknown`"
reveal_type(f // f) # revealed: Unknown reveal_type(f // f) # revealed: Unknown
``` ```

View File

@ -386,7 +386,7 @@ class A(metaclass=Meta): ...
class B(metaclass=Meta): ... class B(metaclass=Meta): ...
reveal_type(A + B) # revealed: int reveal_type(A + B) # revealed: int
# error: [unsupported-operator] "Operator `-` is unsupported between objects of type `<class 'A'>` and `<class 'B'>`" # error: [unsupported-operator] "Operator `-` is not supported between objects of type `<class 'A'>` and `<class 'B'>`"
reveal_type(A - B) # revealed: Unknown reveal_type(A - B) # revealed: Unknown
reveal_type(A < B) # revealed: bool reveal_type(A < B) # revealed: bool
@ -412,7 +412,7 @@ class A:
def __init__(self): def __init__(self):
self.__add__ = add_impl self.__add__ = add_impl
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `A` and `A`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `A` and `A`"
# revealed: Unknown # revealed: Unknown
reveal_type(A() + A()) reveal_type(A() + A())
``` ```

View File

@ -13,7 +13,7 @@ reveal_type(3 | 4) # revealed: Literal[7]
reveal_type(5 & 6) # revealed: Literal[4] reveal_type(5 & 6) # revealed: Literal[4]
reveal_type(7 ^ 2) # revealed: Literal[5] reveal_type(7 ^ 2) # revealed: Literal[5]
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `Literal[2]` and `Literal["f"]`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `Literal[2]` and `Literal["f"]`"
reveal_type(2 + "f") # revealed: Unknown reveal_type(2 + "f") # revealed: Unknown
def lhs(x: int): def lhs(x: int):

View File

@ -5,9 +5,9 @@ combinations of types:
```py ```py
def f1(i: int, u: int | None): def f1(i: int, u: int | None):
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `int` and `int | None`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `int` and `int | None`"
reveal_type(i + u) # revealed: Unknown reveal_type(i + u) # revealed: Unknown
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `int | None` and `int`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `int | None` and `int`"
reveal_type(u + i) # revealed: Unknown reveal_type(u + i) # revealed: Unknown
``` ```
@ -18,7 +18,7 @@ cannot be added, because that would require addition of `int` and `str` or vice
def f2(i: int, s: str, int_or_str: int | str): def f2(i: int, s: str, int_or_str: int | str):
i + i i + i
s + s s + s
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `int | str` and `int | str`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `int | str` and `int | str`"
reveal_type(int_or_str + int_or_str) # revealed: Unknown reveal_type(int_or_str + int_or_str) # revealed: Unknown
``` ```

View File

@ -42,6 +42,6 @@ def _(flag: bool):
class NotBoolable: class NotBoolable:
__bool__: int = 3 __bool__: int = 3
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
3 if NotBoolable() else 4 3 if NotBoolable() else 4
``` ```

View File

@ -154,10 +154,10 @@ def _(flag: bool):
class NotBoolable: class NotBoolable:
__bool__: int = 3 __bool__: int = 3
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
if NotBoolable(): if NotBoolable():
... ...
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
elif NotBoolable(): elif NotBoolable():
... ...
``` ```

View File

@ -378,7 +378,7 @@ class NotBoolable:
def _(target: int, flag: NotBoolable): def _(target: int, flag: NotBoolable):
y = 1 y = 1
match target: match target:
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
case 1 if flag: case 1 if flag:
y = 2 y = 2
case 2: case 2:

View File

@ -4,6 +4,6 @@
class NotBoolable: class NotBoolable:
__bool__: int = 3 __bool__: int = 3
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
assert NotBoolable() assert NotBoolable()
``` ```

View File

@ -232,7 +232,7 @@ if NotBoolable():
class NotBoolable: class NotBoolable:
__bool__: None = None __bool__: None = None
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
if NotBoolable(): if NotBoolable():
... ...
``` ```
@ -244,7 +244,7 @@ def test(cond: bool):
class NotBoolable: class NotBoolable:
__bool__: int | None = None if cond else 3 __bool__: int | None = None if cond else 3
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
if NotBoolable(): if NotBoolable():
... ...
``` ```
@ -258,7 +258,7 @@ def test(cond: bool):
a = 10 if cond else NotBoolable() a = 10 if cond else NotBoolable()
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `Literal[10] | NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `Literal[10] | NotBoolable`"
if a: if a:
... ...
``` ```

View File

@ -277,7 +277,7 @@ T = TypeVar("T", int, str)
def same_constrained_types(t1: T, t2: T) -> T: def same_constrained_types(t1: T, t2: T) -> T:
# TODO: no error # TODO: no error
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `T@same_constrained_types` and `T@same_constrained_types`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `T@same_constrained_types` and `T@same_constrained_types`"
return t1 + t2 return t1 + t2
``` ```
@ -287,7 +287,7 @@ and an `int` and a `str` cannot be added together:
```py ```py
def unions_are_different(t1: int | str, t2: int | str) -> int | str: def unions_are_different(t1: int | str, t2: int | str) -> int | str:
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `int | str` and `int | str`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `int | str` and `int | str`"
return t1 + t2 return t1 + t2
``` ```

View File

@ -246,7 +246,7 @@ methods that are compatible with the return type, so the `return` expression is
```py ```py
def same_constrained_types[T: (int, str)](t1: T, t2: T) -> T: def same_constrained_types[T: (int, str)](t1: T, t2: T) -> T:
# TODO: no error # TODO: no error
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `T@same_constrained_types` and `T@same_constrained_types`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `T@same_constrained_types` and `T@same_constrained_types`"
return t1 + t2 return t1 + t2
``` ```
@ -256,7 +256,7 @@ and an `int` and a `str` cannot be added together:
```py ```py
def unions_are_different(t1: int | str, t2: int | str) -> int | str: def unions_are_different(t1: int | str, t2: int | str) -> int | str:
# error: [unsupported-operator] "Operator `+` is unsupported between objects of type `int | str` and `int | str`" # error: [unsupported-operator] "Operator `+` is not supported between objects of type `int | str` and `int | str`"
return t1 + t2 return t1 + t2
``` ```

View File

@ -214,7 +214,7 @@ def _(int_or_int: IntOrInt, list_of_int_or_list_of_int: ListOfIntOrListOfInt):
`NoneType` has no special or-operator behavior, so this is an error: `NoneType` has no special or-operator behavior, so this is an error:
```py ```py
None | None # error: [unsupported-operator] "Operator `|` is unsupported between objects of type `None` and `None`" None | None # error: [unsupported-operator] "Operator `|` is not supported between objects of type `None` and `None`"
``` ```
When constructing something nonsensical like `int | 1`, we emit a diagnostic for the expression When constructing something nonsensical like `int | 1`, we emit a diagnostic for the expression

View File

@ -123,7 +123,7 @@ def _(flag: bool, flag2: bool):
class NotBoolable: class NotBoolable:
__bool__: int = 3 __bool__: int = 3
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `NotBoolable`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `NotBoolable`"
while NotBoolable(): while NotBoolable():
... ...
``` ```

View File

@ -270,7 +270,7 @@ def _(
if af: if af:
reveal_type(af) # revealed: type[AmbiguousClass] & ~AlwaysFalsy reveal_type(af) # revealed: type[AmbiguousClass] & ~AlwaysFalsy
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `MetaDeferred`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `MetaDeferred`"
if d: if d:
# TODO: Should be `Unknown` # TODO: Should be `Unknown`
reveal_type(d) # revealed: type[DeferredClass] & ~AlwaysFalsy reveal_type(d) # revealed: type[DeferredClass] & ~AlwaysFalsy

View File

@ -19,7 +19,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/assignment/annotations.m
# Diagnostics # Diagnostics
``` ```
error[unsupported-operator]: Operator `|` is unsupported between objects of type `<class 'int'>` and `<class 'str'>` error[unsupported-operator]: Operator `|` is not supported between objects of type `<class 'int'>` and `<class 'str'>`
--> src/mdtest_snippet.py:2:12 --> src/mdtest_snippet.py:2:12
| |
1 | # error: [unsupported-operator] 1 | # error: [unsupported-operator]

View File

@ -24,7 +24,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/binary/instances.md
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:7:8 --> src/mdtest_snippet.py:7:8
| |
6 | # error: [unsupported-bool-conversion] 6 | # error: [unsupported-bool-conversion]

View File

@ -28,7 +28,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/comparison/instances/mem
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:9:1 --> src/mdtest_snippet.py:9:1
| |
8 | # error: [unsupported-bool-conversion] 8 | # error: [unsupported-bool-conversion]
@ -43,7 +43,7 @@ info: rule `unsupported-bool-conversion` is enabled by default
``` ```
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:11:1 --> src/mdtest_snippet.py:11:1
| |
9 | 10 in WithContains() 9 | 10 in WithContains()

View File

@ -22,7 +22,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/unary/not.md
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:5:1 --> src/mdtest_snippet.py:5:1
| |
4 | # error: [unsupported-bool-conversion] 4 | # error: [unsupported-bool-conversion]

View File

@ -33,7 +33,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/comparison/instances/ric
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:12:1 --> src/mdtest_snippet.py:12:1
| |
11 | # error: [unsupported-bool-conversion] 11 | # error: [unsupported-bool-conversion]
@ -48,7 +48,7 @@ info: rule `unsupported-bool-conversion` is enabled by default
``` ```
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:14:1 --> src/mdtest_snippet.py:14:1
| |
12 | 10 < Comparable() < 20 12 | 10 < Comparable() < 20

View File

@ -34,7 +34,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/comparison/tuples.md
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable | Literal[False]` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable | Literal[False]`
--> src/mdtest_snippet.py:15:1 --> src/mdtest_snippet.py:15:1
| |
14 | # error: [unsupported-bool-conversion] 14 | # error: [unsupported-bool-conversion]

View File

@ -58,7 +58,7 @@ info: rule `invalid-method-override` is enabled by default
``` ```
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:10:1 --> src/mdtest_snippet.py:10:1
| |
9 | # error: [unsupported-bool-conversion] 9 | # error: [unsupported-bool-conversion]

View File

@ -24,7 +24,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/unsupported_
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:7:8 --> src/mdtest_snippet.py:7:8
| |
6 | # error: [unsupported-bool-conversion] 6 | # error: [unsupported-bool-conversion]

View File

@ -25,7 +25,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/unsupported_
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:8:8 --> src/mdtest_snippet.py:8:8
| |
7 | # error: [unsupported-bool-conversion] 7 | # error: [unsupported-bool-conversion]

View File

@ -25,7 +25,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/unsupported_
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for type `NotBoolable` error[unsupported-bool-conversion]: Boolean conversion is not supported for type `NotBoolable`
--> src/mdtest_snippet.py:8:8 --> src/mdtest_snippet.py:8:8
| |
7 | # error: [unsupported-bool-conversion] 7 | # error: [unsupported-bool-conversion]

View File

@ -32,7 +32,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/unsupported_
# Diagnostics # Diagnostics
``` ```
error[unsupported-bool-conversion]: Boolean conversion is unsupported for union `NotBoolable1 | NotBoolable2 | NotBoolable3` because `NotBoolable1` doesn't implement `__bool__` correctly error[unsupported-bool-conversion]: Boolean conversion is not supported for union `NotBoolable1 | NotBoolable2 | NotBoolable3` because `NotBoolable1` doesn't implement `__bool__` correctly
--> src/mdtest_snippet.py:15:8 --> src/mdtest_snippet.py:15:8
| |
14 | # error: [unsupported-bool-conversion] 14 | # error: [unsupported-bool-conversion]

View File

@ -237,7 +237,7 @@ class InvalidBoolDunder:
def __bool__(self) -> int: def __bool__(self) -> int:
return 1 return 1
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `InvalidBoolDunder`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `InvalidBoolDunder`"
static_assert(InvalidBoolDunder()) static_assert(InvalidBoolDunder())
``` ```

View File

@ -24,11 +24,11 @@ reveal_type(+Sub()) # revealed: bool
reveal_type(-Sub()) # revealed: str reveal_type(-Sub()) # revealed: str
reveal_type(~Sub()) # revealed: int reveal_type(~Sub()) # revealed: int
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `No`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `No`"
reveal_type(+No()) # revealed: Unknown reveal_type(+No()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `No`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `No`"
reveal_type(-No()) # revealed: Unknown reveal_type(-No()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `No`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `No`"
reveal_type(~No()) # revealed: Unknown reveal_type(~No()) # revealed: Unknown
``` ```
@ -52,25 +52,25 @@ class Yes:
class Sub(Yes): ... class Sub(Yes): ...
class No: ... class No: ...
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `<class 'Yes'>`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `<class 'Yes'>`"
reveal_type(+Yes) # revealed: Unknown reveal_type(+Yes) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `<class 'Yes'>`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `<class 'Yes'>`"
reveal_type(-Yes) # revealed: Unknown reveal_type(-Yes) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `<class 'Yes'>`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `<class 'Yes'>`"
reveal_type(~Yes) # revealed: Unknown reveal_type(~Yes) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `<class 'Sub'>`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `<class 'Sub'>`"
reveal_type(+Sub) # revealed: Unknown reveal_type(+Sub) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `<class 'Sub'>`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `<class 'Sub'>`"
reveal_type(-Sub) # revealed: Unknown reveal_type(-Sub) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `<class 'Sub'>`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `<class 'Sub'>`"
reveal_type(~Sub) # revealed: Unknown reveal_type(~Sub) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `<class 'No'>`"
reveal_type(+No) # revealed: Unknown reveal_type(+No) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `<class 'No'>`"
reveal_type(-No) # revealed: Unknown reveal_type(-No) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `<class 'No'>`"
reveal_type(~No) # revealed: Unknown reveal_type(~No) # revealed: Unknown
``` ```
@ -80,11 +80,11 @@ reveal_type(~No) # revealed: Unknown
def f(): def f():
pass pass
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `def f() -> Unknown`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `def f() -> Unknown`"
reveal_type(+f) # revealed: Unknown reveal_type(+f) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `def f() -> Unknown`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `def f() -> Unknown`"
reveal_type(-f) # revealed: Unknown reveal_type(-f) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `def f() -> Unknown`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `def f() -> Unknown`"
reveal_type(~f) # revealed: Unknown reveal_type(~f) # revealed: Unknown
``` ```
@ -113,25 +113,25 @@ def sub() -> type[Sub]:
def no() -> type[No]: def no() -> type[No]:
return No return No
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `type[Yes]`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `type[Yes]`"
reveal_type(+yes()) # revealed: Unknown reveal_type(+yes()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `type[Yes]`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `type[Yes]`"
reveal_type(-yes()) # revealed: Unknown reveal_type(-yes()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `type[Yes]`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `type[Yes]`"
reveal_type(~yes()) # revealed: Unknown reveal_type(~yes()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `type[Sub]`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `type[Sub]`"
reveal_type(+sub()) # revealed: Unknown reveal_type(+sub()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `type[Sub]`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `type[Sub]`"
reveal_type(-sub()) # revealed: Unknown reveal_type(-sub()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `type[Sub]`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `type[Sub]`"
reveal_type(~sub()) # revealed: Unknown reveal_type(~sub()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `type[No]`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `type[No]`"
reveal_type(+no()) # revealed: Unknown reveal_type(+no()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `type[No]`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `type[No]`"
reveal_type(-no()) # revealed: Unknown reveal_type(-no()) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `type[No]`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `type[No]`"
reveal_type(~no()) # revealed: Unknown reveal_type(~no()) # revealed: Unknown
``` ```
@ -160,10 +160,10 @@ reveal_type(+Sub) # revealed: bool
reveal_type(-Sub) # revealed: str reveal_type(-Sub) # revealed: str
reveal_type(~Sub) # revealed: int reveal_type(~Sub) # revealed: int
# error: [unsupported-operator] "Unary operator `+` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `+` is not supported for type `<class 'No'>`"
reveal_type(+No) # revealed: Unknown reveal_type(+No) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `-` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `-` is not supported for type `<class 'No'>`"
reveal_type(-No) # revealed: Unknown reveal_type(-No) # revealed: Unknown
# error: [unsupported-operator] "Unary operator `~` is unsupported for type `<class 'No'>`" # error: [unsupported-operator] "Unary operator `~` is not supported for type `<class 'No'>`"
reveal_type(~No) # revealed: Unknown reveal_type(~No) # revealed: Unknown
``` ```

View File

@ -27,7 +27,7 @@ reveal_type(~a) # revealed: Literal[True]
class NoDunder: ... class NoDunder: ...
b = NoDunder() b = NoDunder()
+b # error: [unsupported-operator] "Unary operator `+` is unsupported for type `NoDunder`" +b # error: [unsupported-operator] "Unary operator `+` is not supported for type `NoDunder`"
-b # error: [unsupported-operator] "Unary operator `-` is unsupported for type `NoDunder`" -b # error: [unsupported-operator] "Unary operator `-` is not supported for type `NoDunder`"
~b # error: [unsupported-operator] "Unary operator `~` is unsupported for type `NoDunder`" ~b # error: [unsupported-operator] "Unary operator `~` is not supported for type `NoDunder`"
``` ```

View File

@ -187,7 +187,7 @@ class MethodBoolInvalid:
def __bool__(self) -> int: def __bool__(self) -> int:
return 0 return 0
# error: [unsupported-bool-conversion] "Boolean conversion is unsupported for type `MethodBoolInvalid`" # error: [unsupported-bool-conversion] "Boolean conversion is not supported for type `MethodBoolInvalid`"
# revealed: bool # revealed: bool
reveal_type(not MethodBoolInvalid()) reveal_type(not MethodBoolInvalid())

View File

@ -11574,7 +11574,7 @@ impl<'db> BoolError<'db> {
not_boolable_type, .. not_boolable_type, ..
} => { } => {
let mut diag = builder.into_diagnostic(format_args!( let mut diag = builder.into_diagnostic(format_args!(
"Boolean conversion is unsupported for type `{}`", "Boolean conversion is not supported for type `{}`",
not_boolable_type.display(context.db()) not_boolable_type.display(context.db())
)); ));
let mut sub = SubDiagnostic::new( let mut sub = SubDiagnostic::new(
@ -11599,7 +11599,7 @@ impl<'db> BoolError<'db> {
return_type, return_type,
} => { } => {
let mut diag = builder.into_diagnostic(format_args!( let mut diag = builder.into_diagnostic(format_args!(
"Boolean conversion is unsupported for type `{not_boolable}`", "Boolean conversion is not supported for type `{not_boolable}`",
not_boolable = not_boolable_type.display(context.db()), not_boolable = not_boolable_type.display(context.db()),
)); ));
let mut sub = SubDiagnostic::new( let mut sub = SubDiagnostic::new(
@ -11625,7 +11625,7 @@ impl<'db> BoolError<'db> {
} }
Self::NotCallable { not_boolable_type } => { Self::NotCallable { not_boolable_type } => {
let mut diag = builder.into_diagnostic(format_args!( let mut diag = builder.into_diagnostic(format_args!(
"Boolean conversion is unsupported for type `{}`", "Boolean conversion is not supported for type `{}`",
not_boolable_type.display(context.db()) not_boolable_type.display(context.db())
)); ));
let sub = SubDiagnostic::new( let sub = SubDiagnostic::new(
@ -11648,7 +11648,7 @@ impl<'db> BoolError<'db> {
.unwrap(); .unwrap();
builder.into_diagnostic(format_args!( builder.into_diagnostic(format_args!(
"Boolean conversion is unsupported for union `{}` \ "Boolean conversion is not supported for union `{}` \
because `{}` doesn't implement `__bool__` correctly", because `{}` doesn't implement `__bool__` correctly",
Type::Union(*union).display(context.db()), Type::Union(*union).display(context.db()),
first_error.not_boolable_type().display(context.db()), first_error.not_boolable_type().display(context.db()),
@ -11657,7 +11657,7 @@ impl<'db> BoolError<'db> {
Self::Other { not_boolable_type } => { Self::Other { not_boolable_type } => {
builder.into_diagnostic(format_args!( builder.into_diagnostic(format_args!(
"Boolean conversion is unsupported for type `{}`; \ "Boolean conversion is not supported for type `{}`; \
it incorrectly implements `__bool__`", it incorrectly implements `__bool__`",
not_boolable_type.display(context.db()) not_boolable_type.display(context.db())
)); ));

View File

@ -5910,7 +5910,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
return; return;
}; };
builder.into_diagnostic(format_args!( builder.into_diagnostic(format_args!(
"Operator `{op}=` is unsupported between objects of type `{}` and `{}`", "Operator `{op}=` is not supported between objects of type `{}` and `{}`",
target_type.display(db), target_type.display(db),
value_type.display(db) value_type.display(db)
)); ));
@ -9679,7 +9679,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
self.context.report_lint(&UNSUPPORTED_OPERATOR, unary) self.context.report_lint(&UNSUPPORTED_OPERATOR, unary)
{ {
builder.into_diagnostic(format_args!( builder.into_diagnostic(format_args!(
"Unary operator `{op}` is unsupported for type `{}`", "Unary operator `{op}` is not supported for type `{}`",
operand_type.display(self.db()), operand_type.display(self.db()),
)); ));
} }
@ -9716,7 +9716,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
if let Some(builder) = self.context.report_lint(&UNSUPPORTED_OPERATOR, binary) { if let Some(builder) = self.context.report_lint(&UNSUPPORTED_OPERATOR, binary) {
let mut diag = builder.into_diagnostic(format_args!( let mut diag = builder.into_diagnostic(format_args!(
"Operator `{op}` is unsupported between objects of type `{}` and `{}`", "Operator `{op}` is not supported between objects of type `{}` and `{}`",
left_ty.display(db), left_ty.display(db),
right_ty.display(db) right_ty.display(db)
)); ));