treat special type syntax as xml

This commit is contained in:
Aria Desires 2025-12-16 08:39:58 -05:00
parent 0f373603eb
commit 36bf0f3ada
22 changed files with 185 additions and 180 deletions

View File

@ -151,14 +151,19 @@ impl fmt::Display for DisplayHoverContent<'_, '_> {
Some(TypeVarVariance::Bivariant) => " (bivariant)",
None => "",
};
// Special types like `<special-form of whatever 'blahblah' with 'florps'>`
// render poorly with python syntax-highlighting but well as xml
let ty_string = ty
.display_with(self.db, DisplaySettings::default().multiline())
.to_string();
let syntax = if ty_string.starts_with('<') {
"xml"
} else {
"python"
};
self.kind
.fenced_code_block(
format!(
"{}{variance}",
ty.display_with(self.db, DisplaySettings::default().multiline())
),
"python",
)
.fenced_code_block(format!("{ty_string}{variance}"), syntax)
.fmt(f)
}
HoverContent::Docstring(docstring) => docstring.render(self.kind).fmt(f),
@ -358,7 +363,7 @@ mod tests {
Everyone loves my class!!
---------------------------------------------
```python
```xml
<class 'MyClass'>
```
---
@ -420,7 +425,7 @@ mod tests {
Everyone loves my class!!
---------------------------------------------
```python
```xml
<class 'MyClass'>
```
---
@ -480,7 +485,7 @@ mod tests {
initializes MyClass (perfectly)
---------------------------------------------
```python
```xml
<class 'MyClass'>
```
---
@ -536,7 +541,7 @@ mod tests {
initializes MyClass (perfectly)
---------------------------------------------
```python
```xml
<class 'MyClass'>
```
---
@ -595,7 +600,7 @@ mod tests {
Everyone loves my class!!
---------------------------------------------
```python
```xml
<class 'MyClass'>
```
---
@ -1680,7 +1685,7 @@ def ab(a: int, *, c: int):
Wow this module rocks.
---------------------------------------------
```python
```xml
<module 'lib'>
```
---
@ -2029,7 +2034,7 @@ def function():
assert_snapshot!(test.hover(), @r"
<class 'Click'>
---------------------------------------------
```python
```xml
<class 'Click'>
```
---------------------------------------------
@ -2234,7 +2239,7 @@ def function():
Wow this module rocks.
---------------------------------------------
```python
```xml
<module 'lib'>
```
---
@ -3343,7 +3348,7 @@ def function():
assert_snapshot!(test.hover(), @r"
<module 'mypackage.subpkg'>
---------------------------------------------
```python
```xml
<module 'mypackage.subpkg'>
```
---------------------------------------------
@ -3385,7 +3390,7 @@ def function():
assert_snapshot!(test.hover(), @r"
<module 'mypackage.subpkg'>
---------------------------------------------
```python
```xml
<module 'mypackage.subpkg'>
```
---------------------------------------------
@ -3469,7 +3474,7 @@ def function():
assert_snapshot!(test.hover(), @r"
<module 'mypackage.subpkg.submod'>
---------------------------------------------
```python
```xml
<module 'mypackage.subpkg.submod'>
```
---------------------------------------------
@ -3510,7 +3515,7 @@ def function():
assert_snapshot!(test.hover(), @r"
<module 'mypackage.subpkg'>
---------------------------------------------
```python
```xml
<module 'mypackage.subpkg'>
```
---------------------------------------------

View File

@ -6216,7 +6216,7 @@ mod tests {
assert_snapshot!(test.inlay_hints(), @r#"
from typing import Literal
a[: <special form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
a[: <special-form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
---------------------------------------------
info[inlay-hint-location]: Inlay Hint Target
--> stdlib/typing.pyi:351:1
@ -6232,7 +6232,7 @@ mod tests {
|
2 | from typing import Literal
3 |
4 | a[: <special form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
4 | a[: <special-form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
| ^^^^^^^
|
@ -6250,7 +6250,7 @@ mod tests {
|
2 | from typing import Literal
3 |
4 | a[: <special form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
4 | a[: <special-form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
| ^^^
|
@ -6268,7 +6268,7 @@ mod tests {
|
2 | from typing import Literal
3 |
4 | a[: <special form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
4 | a[: <special-form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
| ^^^
|
@ -6286,7 +6286,7 @@ mod tests {
|
2 | from typing import Literal
3 |
4 | a[: <special form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
4 | a[: <special-form 'Literal["a", "b", "c"]'>] = Literal['a', 'b', 'c']
| ^^^
|
"#);
@ -6636,7 +6636,7 @@ mod tests {
assert_snapshot!(test.inlay_hints(), @r"
from typing import Protocol, TypeVar
T = TypeVar([name=]'T')
Strange[: <special form 'typing.Protocol[T]'>] = Protocol[T]
Strange[: <special-form 'typing.Protocol[T]'>] = Protocol[T]
---------------------------------------------
info[inlay-hint-location]: Inlay Hint Target
--> stdlib/typing.pyi:276:13
@ -6654,7 +6654,7 @@ mod tests {
2 | from typing import Protocol, TypeVar
3 | T = TypeVar([name=]'T')
| ^^^^
4 | Strange[: <special form 'typing.Protocol[T]'>] = Protocol[T]
4 | Strange[: <special-form 'typing.Protocol[T]'>] = Protocol[T]
|
info[inlay-hint-location]: Inlay Hint Target
@ -6671,7 +6671,7 @@ mod tests {
|
2 | from typing import Protocol, TypeVar
3 | T = TypeVar([name=]'T')
4 | Strange[: <special form 'typing.Protocol[T]'>] = Protocol[T]
4 | Strange[: <special-form 'typing.Protocol[T]'>] = Protocol[T]
| ^^^^^^^^^^^^^^^
|
@ -6688,7 +6688,7 @@ mod tests {
|
2 | from typing import Protocol, TypeVar
3 | T = TypeVar([name=]'T')
4 | Strange[: <special form 'typing.Protocol[T]'>] = Protocol[T]
4 | Strange[: <special-form 'typing.Protocol[T]'>] = Protocol[T]
| ^
|
");

View File

@ -169,13 +169,13 @@ def f(x: Any[int]):
`Any` cannot be called (this leads to a `TypeError` at runtime):
```py
Any() # error: [call-non-callable] "Object of type `<special form 'typing.Any'>` is not callable"
Any() # error: [call-non-callable] "Object of type `<special-form 'typing.Any'>` is not callable"
```
`Any` also cannot be used as a metaclass (under the hood, this leads to an implicit call to `Any`):
```py
class F(metaclass=Any): ... # error: [invalid-metaclass] "Metaclass type `<special form 'typing.Any'>` is not callable"
class F(metaclass=Any): ... # error: [invalid-metaclass] "Metaclass type `<special-form 'typing.Any'>` is not callable"
```
And `Any` cannot be used in `isinstance()` checks:

View File

@ -59,7 +59,7 @@ python-version = "3.11"
```py
from typing import Never
reveal_type(Never) # revealed: <special form 'typing.Never'>
reveal_type(Never) # revealed: <special-form 'typing.Never'>
```
### Python 3.10

View File

@ -13,7 +13,7 @@ python-version = "3.10"
class A: ...
class B: ...
reveal_type(A | B) # revealed: <types.UnionType special form 'A | B'>
reveal_type(A | B) # revealed: <types.UnionType special-form 'A | B'>
```
## Union of two classes (prior to 3.10)
@ -43,14 +43,14 @@ class A: ...
class B: ...
def _(sub_a: type[A], sub_b: type[B]):
reveal_type(A | sub_b) # revealed: <types.UnionType special form>
reveal_type(sub_a | B) # revealed: <types.UnionType special form>
reveal_type(sub_a | sub_b) # revealed: <types.UnionType special form>
reveal_type(A | sub_b) # revealed: <types.UnionType special-form>
reveal_type(sub_a | B) # revealed: <types.UnionType special-form>
reveal_type(sub_a | sub_b) # revealed: <types.UnionType special-form>
class C[T]: ...
class D[T]: ...
reveal_type(C | D) # revealed: <types.UnionType special form 'C[Unknown] | D[Unknown]'>
reveal_type(C | D) # revealed: <types.UnionType special-form 'C[Unknown] | D[Unknown]'>
reveal_type(C[int] | D[str]) # revealed: <types.UnionType special form 'C[int] | D[str]'>
reveal_type(C[int] | D[str]) # revealed: <types.UnionType special-form 'C[int] | D[str]'>
```

View File

@ -602,13 +602,13 @@ super(object, object()).__class__
# Not all objects valid in a class's bases list are valid as the first argument to `super()`.
# For example, it's valid to inherit from `typing.ChainMap`, but it's not valid as the first argument to `super()`.
#
# error: [invalid-super-argument] "`<special form 'typing.ChainMap'>` is not a valid class"
# error: [invalid-super-argument] "`<special-form 'typing.ChainMap'>` is not a valid class"
reveal_type(super(typing.ChainMap, collections.ChainMap())) # revealed: Unknown
# Meanwhile, it's not valid to inherit from unsubscripted `typing.Generic`,
# but it *is* valid as the first argument to `super()`.
#
# revealed: <super: <special form 'typing.Generic'>, <class 'SupportsInt'>>
# revealed: <super: <special-form 'typing.Generic'>, <class 'SupportsInt'>>
reveal_type(super(typing.Generic, typing.SupportsInt))
def _(x: type[typing.Any], y: typing.Any):

View File

@ -80,7 +80,7 @@ class Foo(Protocol):
def f[T](self, v: T) -> T: ...
t = (Protocol, int)
reveal_type(t[0]) # revealed: <special form 'typing.Protocol'>
reveal_type(t[0]) # revealed: <special-form 'typing.Protocol'>
class Lorem(t[0]):
def f(self) -> int: ...

View File

@ -77,44 +77,44 @@ IntOrTypeVar = int | T
TypeVarOrNone = T | None
NoneOrTypeVar = None | T
reveal_type(IntOrStr) # revealed: <types.UnionType special form 'int | str'>
reveal_type(IntOrStrOrBytes1) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes2) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes3) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes4) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes5) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes6) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(BytesOrIntOrStr) # revealed: <types.UnionType special form 'bytes | int | str'>
reveal_type(IntOrNone) # revealed: <types.UnionType special form 'int | None'>
reveal_type(NoneOrInt) # revealed: <types.UnionType special form 'None | int'>
reveal_type(IntOrStrOrNone) # revealed: <types.UnionType special form 'int | str | None'>
reveal_type(NoneOrIntOrStr) # revealed: <types.UnionType special form 'None | int | str'>
reveal_type(IntOrAny) # revealed: <types.UnionType special form 'int | Any'>
reveal_type(AnyOrInt) # revealed: <types.UnionType special form 'Any | int'>
reveal_type(NoneOrAny) # revealed: <types.UnionType special form 'None | Any'>
reveal_type(AnyOrNone) # revealed: <types.UnionType special form 'Any | None'>
reveal_type(NeverOrAny) # revealed: <types.UnionType special form 'Any'>
reveal_type(AnyOrNever) # revealed: <types.UnionType special form 'Any'>
reveal_type(UnknownOrInt) # revealed: <types.UnionType special form 'Unknown | int'>
reveal_type(IntOrUnknown) # revealed: <types.UnionType special form 'int | Unknown'>
reveal_type(StrOrZero) # revealed: <types.UnionType special form 'str | Literal[0]'>
reveal_type(ZeroOrStr) # revealed: <types.UnionType special form 'Literal[0] | str'>
reveal_type(IntOrLiteralString) # revealed: <types.UnionType special form 'int | LiteralString'>
reveal_type(LiteralStringOrInt) # revealed: <types.UnionType special form 'LiteralString | int'>
reveal_type(NoneOrTuple) # revealed: <types.UnionType special form 'None | tuple[int, str]'>
reveal_type(TupleOrNone) # revealed: <types.UnionType special form 'tuple[int, str] | None'>
reveal_type(IntOrAnnotated) # revealed: <types.UnionType special form 'int | str'>
reveal_type(AnnotatedOrInt) # revealed: <types.UnionType special form 'str | int'>
reveal_type(IntOrOptional) # revealed: <types.UnionType special form 'int | str | None'>
reveal_type(OptionalOrInt) # revealed: <types.UnionType special form 'str | None | int'>
reveal_type(IntOrTypeOfStr) # revealed: <types.UnionType special form 'int | type[str]'>
reveal_type(TypeOfStrOrInt) # revealed: <types.UnionType special form 'type[str] | int'>
reveal_type(IntOrCallable) # revealed: <types.UnionType special form 'int | ((str, /) -> bytes)'>
reveal_type(CallableOrInt) # revealed: <types.UnionType special form '((str, /) -> bytes) | int'>
reveal_type(TypeVarOrInt) # revealed: <types.UnionType special form 'T@TypeVarOrInt | int'>
reveal_type(IntOrTypeVar) # revealed: <types.UnionType special form 'int | T@IntOrTypeVar'>
reveal_type(TypeVarOrNone) # revealed: <types.UnionType special form 'T@TypeVarOrNone | None'>
reveal_type(NoneOrTypeVar) # revealed: <types.UnionType special form 'None | T@NoneOrTypeVar'>
reveal_type(IntOrStr) # revealed: <types.UnionType special-form 'int | str'>
reveal_type(IntOrStrOrBytes1) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes2) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes3) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes4) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes5) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(IntOrStrOrBytes6) # revealed: <types.UnionType special-form 'int | str | bytes'>
reveal_type(BytesOrIntOrStr) # revealed: <types.UnionType special-form 'bytes | int | str'>
reveal_type(IntOrNone) # revealed: <types.UnionType special-form 'int | None'>
reveal_type(NoneOrInt) # revealed: <types.UnionType special-form 'None | int'>
reveal_type(IntOrStrOrNone) # revealed: <types.UnionType special-form 'int | str | None'>
reveal_type(NoneOrIntOrStr) # revealed: <types.UnionType special-form 'None | int | str'>
reveal_type(IntOrAny) # revealed: <types.UnionType special-form 'int | Any'>
reveal_type(AnyOrInt) # revealed: <types.UnionType special-form 'Any | int'>
reveal_type(NoneOrAny) # revealed: <types.UnionType special-form 'None | Any'>
reveal_type(AnyOrNone) # revealed: <types.UnionType special-form 'Any | None'>
reveal_type(NeverOrAny) # revealed: <types.UnionType special-form 'Any'>
reveal_type(AnyOrNever) # revealed: <types.UnionType special-form 'Any'>
reveal_type(UnknownOrInt) # revealed: <types.UnionType special-form 'Unknown | int'>
reveal_type(IntOrUnknown) # revealed: <types.UnionType special-form 'int | Unknown'>
reveal_type(StrOrZero) # revealed: <types.UnionType special-form 'str | Literal[0]'>
reveal_type(ZeroOrStr) # revealed: <types.UnionType special-form 'Literal[0] | str'>
reveal_type(IntOrLiteralString) # revealed: <types.UnionType special-form 'int | LiteralString'>
reveal_type(LiteralStringOrInt) # revealed: <types.UnionType special-form 'LiteralString | int'>
reveal_type(NoneOrTuple) # revealed: <types.UnionType special-form 'None | tuple[int, str]'>
reveal_type(TupleOrNone) # revealed: <types.UnionType special-form 'tuple[int, str] | None'>
reveal_type(IntOrAnnotated) # revealed: <types.UnionType special-form 'int | str'>
reveal_type(AnnotatedOrInt) # revealed: <types.UnionType special-form 'str | int'>
reveal_type(IntOrOptional) # revealed: <types.UnionType special-form 'int | str | None'>
reveal_type(OptionalOrInt) # revealed: <types.UnionType special-form 'str | None | int'>
reveal_type(IntOrTypeOfStr) # revealed: <types.UnionType special-form 'int | type[str]'>
reveal_type(TypeOfStrOrInt) # revealed: <types.UnionType special-form 'type[str] | int'>
reveal_type(IntOrCallable) # revealed: <types.UnionType special-form 'int | ((str, /) -> bytes)'>
reveal_type(CallableOrInt) # revealed: <types.UnionType special-form '((str, /) -> bytes) | int'>
reveal_type(TypeVarOrInt) # revealed: <types.UnionType special-form 'T@TypeVarOrInt | int'>
reveal_type(IntOrTypeVar) # revealed: <types.UnionType special-form 'int | T@IntOrTypeVar'>
reveal_type(TypeVarOrNone) # revealed: <types.UnionType special-form 'T@TypeVarOrNone | None'>
reveal_type(NoneOrTypeVar) # revealed: <types.UnionType special-form 'None | T@NoneOrTypeVar'>
def _(
int_or_str: IntOrStr,
@ -295,7 +295,7 @@ X = Foo | Bar
# In an ideal world, perhaps we would respect `Meta.__or__` here and reveal `str`?
# But we still need to record what the elements are, since (according to the typing spec)
# `X` is still a valid type alias
reveal_type(X) # revealed: <types.UnionType special form 'Foo | Bar'>
reveal_type(X) # revealed: <types.UnionType special-form 'Foo | Bar'>
def f(obj: X):
reveal_type(obj) # revealed: Foo | Bar
@ -391,17 +391,17 @@ MyOptional = T | None
reveal_type(MyList) # revealed: <class 'list[T@MyList]'>
reveal_type(MyDict) # revealed: <class 'dict[T@MyDict, U@MyDict]'>
reveal_type(MyType) # revealed: <special form 'type[T@MyType]'>
reveal_type(MyType) # revealed: <special-form 'type[T@MyType]'>
reveal_type(IntAndType) # revealed: <class 'tuple[int, T@IntAndType]'>
reveal_type(Pair) # revealed: <class 'tuple[T@Pair, T@Pair]'>
reveal_type(Sum) # revealed: <class 'tuple[T@Sum, U@Sum]'>
reveal_type(ListOrTuple) # revealed: <types.UnionType special form 'list[T@ListOrTuple] | tuple[T@ListOrTuple, ...]'>
# revealed: <types.UnionType special form 'list[T@ListOrTupleLegacy] | tuple[T@ListOrTupleLegacy, ...]'>
reveal_type(ListOrTuple) # revealed: <types.UnionType special-form 'list[T@ListOrTuple] | tuple[T@ListOrTuple, ...]'>
# revealed: <types.UnionType special-form 'list[T@ListOrTupleLegacy] | tuple[T@ListOrTupleLegacy, ...]'>
reveal_type(ListOrTupleLegacy)
reveal_type(MyCallable) # revealed: <typing.Callable special form '(**P@MyCallable) -> T@MyCallable'>
reveal_type(AnnotatedType) # revealed: <special form 'typing.Annotated[T@AnnotatedType, <metadata>]'>
reveal_type(MyCallable) # revealed: <typing.Callable special-form '(**P@MyCallable) -> T@MyCallable'>
reveal_type(AnnotatedType) # revealed: <special-form 'typing.Annotated[T@AnnotatedType, <metadata>]'>
reveal_type(TransparentAlias) # revealed: TypeVar
reveal_type(MyOptional) # revealed: <types.UnionType special form 'T@MyOptional | None'>
reveal_type(MyOptional) # revealed: <types.UnionType special-form 'T@MyOptional | None'>
def _(
list_of_ints: MyList[int],
@ -457,13 +457,13 @@ AnnotatedInt = AnnotatedType[int]
SubclassOfInt = MyType[int]
CallableIntToStr = MyCallable[[int], str]
reveal_type(IntsOrNone) # revealed: <types.UnionType special form 'list[int] | None'>
reveal_type(IntsOrStrs) # revealed: <types.UnionType special form 'tuple[int, int] | tuple[str, str]'>
reveal_type(IntsOrNone) # revealed: <types.UnionType special-form 'list[int] | None'>
reveal_type(IntsOrStrs) # revealed: <types.UnionType special-form 'tuple[int, int] | tuple[str, str]'>
reveal_type(ListOfPairs) # revealed: <class 'list[tuple[str, str]]'>
reveal_type(ListOrTupleOfInts) # revealed: <types.UnionType special form 'list[int] | tuple[int, ...]'>
reveal_type(AnnotatedInt) # revealed: <special form 'typing.Annotated[int, <metadata>]'>
reveal_type(SubclassOfInt) # revealed: <special form 'type[int]'>
reveal_type(CallableIntToStr) # revealed: <typing.Callable special form '(int, /) -> str'>
reveal_type(ListOrTupleOfInts) # revealed: <types.UnionType special-form 'list[int] | tuple[int, ...]'>
reveal_type(AnnotatedInt) # revealed: <special-form 'typing.Annotated[int, <metadata>]'>
reveal_type(SubclassOfInt) # revealed: <special-form 'type[int]'>
reveal_type(CallableIntToStr) # revealed: <typing.Callable special-form '(int, /) -> str'>
def _(
ints_or_none: IntsOrNone,
@ -495,8 +495,8 @@ MyOtherType = MyType[T]
TypeOrList = MyType[B] | MyList[B]
reveal_type(MyOtherList) # revealed: <class 'list[T@MyOtherList]'>
reveal_type(MyOtherType) # revealed: <special form 'type[T@MyOtherType]'>
reveal_type(TypeOrList) # revealed: <types.UnionType special form 'type[B@TypeOrList] | list[B@TypeOrList]'>
reveal_type(MyOtherType) # revealed: <special-form 'type[T@MyOtherType]'>
reveal_type(TypeOrList) # revealed: <types.UnionType special-form 'type[B@TypeOrList] | list[B@TypeOrList]'>
def _(
list_of_ints: MyOtherList[int],
@ -730,7 +730,7 @@ def _(doubly_specialized: DictInt[int]):
Union = list[str] | list[int]
# error: [non-subscriptable] "Cannot subscript non-generic type: `<types.UnionType special form 'list[str] | list[int]'>` is already specialized"
# error: [non-subscriptable] "Cannot subscript non-generic type: `<types.UnionType special-form 'list[str] | list[int]'>` is already specialized"
def _(doubly_specialized: Union[int]):
reveal_type(doubly_specialized) # revealed: Unknown
@ -974,7 +974,7 @@ from typing import Optional
MyOptionalInt = Optional[int]
reveal_type(MyOptionalInt) # revealed: <types.UnionType special form 'int | None'>
reveal_type(MyOptionalInt) # revealed: <types.UnionType special-form 'int | None'>
def _(optional_int: MyOptionalInt):
reveal_type(optional_int) # revealed: int | None
@ -1007,9 +1007,9 @@ MyLiteralString = LiteralString
MyNoReturn = NoReturn
MyNever = Never
reveal_type(MyLiteralString) # revealed: <special form 'typing.LiteralString'>
reveal_type(MyNoReturn) # revealed: <special form 'typing.NoReturn'>
reveal_type(MyNever) # revealed: <special form 'typing.Never'>
reveal_type(MyLiteralString) # revealed: <special-form 'typing.LiteralString'>
reveal_type(MyNoReturn) # revealed: <special-form 'typing.NoReturn'>
reveal_type(MyNever) # revealed: <special-form 'typing.Never'>
def _(
ls: MyLiteralString,
@ -1062,8 +1062,8 @@ from typing import Union
IntOrStr = Union[int, str]
IntOrStrOrBytes = Union[int, Union[str, bytes]]
reveal_type(IntOrStr) # revealed: <types.UnionType special form 'int | str'>
reveal_type(IntOrStrOrBytes) # revealed: <types.UnionType special form 'int | str | bytes'>
reveal_type(IntOrStr) # revealed: <types.UnionType special-form 'int | str'>
reveal_type(IntOrStrOrBytes) # revealed: <types.UnionType special-form 'int | str | bytes'>
def _(
int_or_str: IntOrStr,
@ -1091,7 +1091,7 @@ An empty `typing.Union` leads to a `TypeError` at runtime, so we emit an error.
# error: [invalid-type-form] "`typing.Union` requires at least one type argument"
EmptyUnion = Union[()]
reveal_type(EmptyUnion) # revealed: <types.UnionType special form 'Never'>
reveal_type(EmptyUnion) # revealed: <types.UnionType special-form 'Never'>
def _(empty: EmptyUnion):
reveal_type(empty) # revealed: Never
@ -1136,14 +1136,14 @@ SubclassOfG = type[G]
SubclassOfGInt = type[G[int]]
SubclassOfP = type[P]
reveal_type(SubclassOfA) # revealed: <special form 'type[A]'>
reveal_type(SubclassOfAny) # revealed: <special form 'type[Any]'>
reveal_type(SubclassOfAOrB1) # revealed: <special form 'type[A | B]'>
reveal_type(SubclassOfAOrB2) # revealed: <types.UnionType special form 'type[A] | type[B]'>
reveal_type(SubclassOfAOrB3) # revealed: <types.UnionType special form 'type[A] | type[B]'>
reveal_type(SubclassOfG) # revealed: <special form 'type[G[Unknown]]'>
reveal_type(SubclassOfGInt) # revealed: <special form 'type[G[int]]'>
reveal_type(SubclassOfP) # revealed: <special form 'type[P]'>
reveal_type(SubclassOfA) # revealed: <special-form 'type[A]'>
reveal_type(SubclassOfAny) # revealed: <special-form 'type[Any]'>
reveal_type(SubclassOfAOrB1) # revealed: <special-form 'type[A | B]'>
reveal_type(SubclassOfAOrB2) # revealed: <types.UnionType special-form 'type[A] | type[B]'>
reveal_type(SubclassOfAOrB3) # revealed: <types.UnionType special-form 'type[A] | type[B]'>
reveal_type(SubclassOfG) # revealed: <special-form 'type[G[Unknown]]'>
reveal_type(SubclassOfGInt) # revealed: <special-form 'type[G[int]]'>
reveal_type(SubclassOfP) # revealed: <special-form 'type[P]'>
def _(
subclass_of_a: SubclassOfA,
@ -1224,14 +1224,14 @@ SubclassOfG = Type[G]
SubclassOfGInt = Type[G[int]]
SubclassOfP = Type[P]
reveal_type(SubclassOfA) # revealed: <special form 'type[A]'>
reveal_type(SubclassOfAny) # revealed: <special form 'type[Any]'>
reveal_type(SubclassOfAOrB1) # revealed: <special form 'type[A | B]'>
reveal_type(SubclassOfAOrB2) # revealed: <types.UnionType special form 'type[A] | type[B]'>
reveal_type(SubclassOfAOrB3) # revealed: <types.UnionType special form 'type[A] | type[B]'>
reveal_type(SubclassOfG) # revealed: <special form 'type[G[Unknown]]'>
reveal_type(SubclassOfGInt) # revealed: <special form 'type[G[int]]'>
reveal_type(SubclassOfP) # revealed: <special form 'type[P]'>
reveal_type(SubclassOfA) # revealed: <special-form 'type[A]'>
reveal_type(SubclassOfAny) # revealed: <special-form 'type[Any]'>
reveal_type(SubclassOfAOrB1) # revealed: <special-form 'type[A | B]'>
reveal_type(SubclassOfAOrB2) # revealed: <types.UnionType special-form 'type[A] | type[B]'>
reveal_type(SubclassOfAOrB3) # revealed: <types.UnionType special-form 'type[A] | type[B]'>
reveal_type(SubclassOfG) # revealed: <special-form 'type[G[Unknown]]'>
reveal_type(SubclassOfGInt) # revealed: <special-form 'type[G[int]]'>
reveal_type(SubclassOfP) # revealed: <special-form 'type[P]'>
def _(
subclass_of_a: SubclassOfA,
@ -1346,25 +1346,25 @@ DefaultDictOrNone = DefaultDict[str, int] | None
DequeOrNone = Deque[str] | None
OrderedDictOrNone = OrderedDict[str, int] | None
reveal_type(NoneOrList) # revealed: <types.UnionType special form 'None | list[str]'>
reveal_type(NoneOrSet) # revealed: <types.UnionType special form 'None | set[str]'>
reveal_type(NoneOrDict) # revealed: <types.UnionType special form 'None | dict[str, int]'>
reveal_type(NoneOrFrozenSet) # revealed: <types.UnionType special form 'None | frozenset[str]'>
reveal_type(NoneOrChainMap) # revealed: <types.UnionType special form 'None | ChainMap[str, int]'>
reveal_type(NoneOrCounter) # revealed: <types.UnionType special form 'None | Counter[str]'>
reveal_type(NoneOrDefaultDict) # revealed: <types.UnionType special form 'None | defaultdict[str, int]'>
reveal_type(NoneOrDeque) # revealed: <types.UnionType special form 'None | deque[str]'>
reveal_type(NoneOrOrderedDict) # revealed: <types.UnionType special form 'None | OrderedDict[str, int]'>
reveal_type(NoneOrList) # revealed: <types.UnionType special-form 'None | list[str]'>
reveal_type(NoneOrSet) # revealed: <types.UnionType special-form 'None | set[str]'>
reveal_type(NoneOrDict) # revealed: <types.UnionType special-form 'None | dict[str, int]'>
reveal_type(NoneOrFrozenSet) # revealed: <types.UnionType special-form 'None | frozenset[str]'>
reveal_type(NoneOrChainMap) # revealed: <types.UnionType special-form 'None | ChainMap[str, int]'>
reveal_type(NoneOrCounter) # revealed: <types.UnionType special-form 'None | Counter[str]'>
reveal_type(NoneOrDefaultDict) # revealed: <types.UnionType special-form 'None | defaultdict[str, int]'>
reveal_type(NoneOrDeque) # revealed: <types.UnionType special-form 'None | deque[str]'>
reveal_type(NoneOrOrderedDict) # revealed: <types.UnionType special-form 'None | OrderedDict[str, int]'>
reveal_type(ListOrNone) # revealed: <types.UnionType special form 'list[int] | None'>
reveal_type(SetOrNone) # revealed: <types.UnionType special form 'set[int] | None'>
reveal_type(DictOrNone) # revealed: <types.UnionType special form 'dict[str, int] | None'>
reveal_type(FrozenSetOrNone) # revealed: <types.UnionType special form 'frozenset[int] | None'>
reveal_type(ChainMapOrNone) # revealed: <types.UnionType special form 'ChainMap[str, int] | None'>
reveal_type(CounterOrNone) # revealed: <types.UnionType special form 'Counter[str] | None'>
reveal_type(DefaultDictOrNone) # revealed: <types.UnionType special form 'defaultdict[str, int] | None'>
reveal_type(DequeOrNone) # revealed: <types.UnionType special form 'deque[str] | None'>
reveal_type(OrderedDictOrNone) # revealed: <types.UnionType special form 'OrderedDict[str, int] | None'>
reveal_type(ListOrNone) # revealed: <types.UnionType special-form 'list[int] | None'>
reveal_type(SetOrNone) # revealed: <types.UnionType special-form 'set[int] | None'>
reveal_type(DictOrNone) # revealed: <types.UnionType special-form 'dict[str, int] | None'>
reveal_type(FrozenSetOrNone) # revealed: <types.UnionType special-form 'frozenset[int] | None'>
reveal_type(ChainMapOrNone) # revealed: <types.UnionType special-form 'ChainMap[str, int] | None'>
reveal_type(CounterOrNone) # revealed: <types.UnionType special-form 'Counter[str] | None'>
reveal_type(DefaultDictOrNone) # revealed: <types.UnionType special-form 'defaultdict[str, int] | None'>
reveal_type(DequeOrNone) # revealed: <types.UnionType special-form 'deque[str] | None'>
reveal_type(OrderedDictOrNone) # revealed: <types.UnionType special-form 'OrderedDict[str, int] | None'>
def _(
none_or_list: NoneOrList,
@ -1457,9 +1457,9 @@ CallableNoArgs = Callable[[], None]
BasicCallable = Callable[[int, str], bytes]
GradualCallable = Callable[..., str]
reveal_type(CallableNoArgs) # revealed: <typing.Callable special form '() -> None'>
reveal_type(BasicCallable) # revealed: <typing.Callable special form '(int, str, /) -> bytes'>
reveal_type(GradualCallable) # revealed: <typing.Callable special form '(...) -> str'>
reveal_type(CallableNoArgs) # revealed: <typing.Callable special-form '() -> None'>
reveal_type(BasicCallable) # revealed: <typing.Callable special-form '(int, str, /) -> bytes'>
reveal_type(GradualCallable) # revealed: <typing.Callable special-form '(...) -> str'>
def _(
callable_no_args: CallableNoArgs,
@ -1491,8 +1491,8 @@ InvalidCallable1 = Callable[[int]]
# error: [invalid-type-form] "The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`"
InvalidCallable2 = Callable[int, str]
reveal_type(InvalidCallable1) # revealed: <typing.Callable special form '(...) -> Unknown'>
reveal_type(InvalidCallable2) # revealed: <typing.Callable special form '(...) -> Unknown'>
reveal_type(InvalidCallable1) # revealed: <typing.Callable special-form '(...) -> Unknown'>
reveal_type(InvalidCallable2) # revealed: <typing.Callable special-form '(...) -> Unknown'>
def _(invalid_callable1: InvalidCallable1, invalid_callable2: InvalidCallable2):
reveal_type(invalid_callable1) # revealed: (...) -> Unknown

View File

@ -53,8 +53,8 @@ in `import os.path as os.path` the `os.path` is not a valid identifier.
```py
from b import Any, Literal, foo
reveal_type(Any) # revealed: <special form 'typing.Any'>
reveal_type(Literal) # revealed: <special form 'typing.Literal'>
reveal_type(Any) # revealed: <special-form 'typing.Any'>
reveal_type(Literal) # revealed: <special-form 'typing.Literal'>
reveal_type(foo) # revealed: <module 'foo'>
```
@ -132,7 +132,7 @@ reveal_type(Any) # revealed: Unknown
```pyi
from typing import Any
reveal_type(Any) # revealed: <special form 'typing.Any'>
reveal_type(Any) # revealed: <special-form 'typing.Any'>
```
## Nested mixed re-export and not
@ -169,7 +169,7 @@ reveal_type(Any) # revealed: Unknown
```pyi
from typing import Any
reveal_type(Any) # revealed: <special form 'typing.Any'>
reveal_type(Any) # revealed: <special-form 'typing.Any'>
```
## Exported as different name

View File

@ -1437,7 +1437,7 @@ are present due to `*` imports.
import collections.abc
reveal_type(collections.abc.Sequence) # revealed: <class 'Sequence'>
reveal_type(collections.abc.Callable) # revealed: <special form 'typing.Callable'>
reveal_type(collections.abc.Callable) # revealed: <special-form 'typing.Callable'>
reveal_type(collections.abc.Set) # revealed: <class 'AbstractSet'>
```

View File

@ -301,7 +301,7 @@ class B: ...
EitherOr = A | B
# error: [invalid-base] "Invalid class base with type `<types.UnionType special form 'A | B'>`"
# error: [invalid-base] "Invalid class base with type `<types.UnionType special-form 'A | B'>`"
class Foo(EitherOr): ...
```

View File

@ -156,7 +156,7 @@ from typing import Union
IntOrStr = Union[int, str]
reveal_type(IntOrStr) # revealed: <types.UnionType special form 'int | str'>
reveal_type(IntOrStr) # revealed: <types.UnionType special-form 'int | str'>
def _(x: int | str | bytes | memoryview | range):
if isinstance(x, IntOrStr):

View File

@ -209,7 +209,7 @@ from typing import Union
IntOrStr = Union[int, str]
reveal_type(IntOrStr) # revealed: <types.UnionType special form 'int | str'>
reveal_type(IntOrStr) # revealed: <types.UnionType special-form 'int | str'>
def f(x: type[int | str | bytes | range]):
if issubclass(x, IntOrStr):

View File

@ -113,7 +113,7 @@ MyList: TypeAlias = list[T]
ListOrSet: TypeAlias = list[T] | set[T]
reveal_type(MyList) # revealed: <class 'list[T]'>
reveal_type(ListOrSet) # revealed: <types.UnionType special form 'list[T] | set[T]'>
reveal_type(ListOrSet) # revealed: <types.UnionType special-form 'list[T] | set[T]'>
def _(list_of_int: MyList[int], list_or_set_of_str: ListOrSet[str]):
reveal_type(list_of_int) # revealed: list[int]
@ -293,7 +293,7 @@ def _(rec: RecursiveHomogeneousTuple):
reveal_type(rec) # revealed: tuple[Divergent, ...]
ClassInfo: TypeAlias = type | UnionType | tuple["ClassInfo", ...]
reveal_type(ClassInfo) # revealed: <types.UnionType special form 'type | UnionType | tuple[Divergent, ...]'>
reveal_type(ClassInfo) # revealed: <types.UnionType special-form 'type | UnionType | tuple[Divergent, ...]'>
def my_isinstance(obj: object, classinfo: ClassInfo) -> bool:
# TODO should be `type | UnionType | tuple[ClassInfo, ...]`

View File

@ -63,7 +63,7 @@ error[invalid-argument-type]: Invalid second argument to `isinstance`
10 | # error: [invalid-argument-type]
|
info: A `UnionType` instance can only be used as the second argument to `isinstance` if all elements are class objects
info: Elements `<special form 'Literal[42]'>` and `<class 'list[int]'>` in the union are not class objects
info: Elements `<special-form 'Literal[42]'>` and `<class 'list[int]'>` in the union are not class objects
info: rule `invalid-argument-type` is enabled by default
```
@ -82,7 +82,7 @@ error[invalid-argument-type]: Invalid second argument to `isinstance`
13 | else:
|
info: A `UnionType` instance can only be used as the second argument to `isinstance` if all elements are class objects
info: Element `<special form 'typing.Any'>` in the union, and 2 more elements, are not class objects
info: Element `<special-form 'typing.Any'>` in the union, and 2 more elements, are not class objects
info: rule `invalid-argument-type` is enabled by default
```

View File

@ -24,7 +24,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/mro.md
# Diagnostics
```
error[inconsistent-mro]: Cannot create a consistent method resolution order (MRO) for class `Baz` with bases list `[<special form 'typing.Protocol[T]'>, <class 'Foo'>, <class 'Bar[T@Baz]'>]`
error[inconsistent-mro]: Cannot create a consistent method resolution order (MRO) for class `Baz` with bases list `[<special-form 'typing.Protocol[T]'>, <class 'Foo'>, <class 'Bar[T@Baz]'>]`
--> src/mdtest_snippet.py:7:1
|
5 | class Foo(Protocol): ...

View File

@ -42,7 +42,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/protocols.md
# Diagnostics
```
error[call-non-callable]: Object of type `<special form 'typing.Protocol'>` is not callable
error[call-non-callable]: Object of type `<special-form 'typing.Protocol'>` is not callable
--> src/mdtest_snippet.py:4:13
|
3 | # error: [call-non-callable]

View File

@ -709,7 +709,7 @@ impl<'db> FmtDetailed<'db> for DisplayRepresentation<'db> {
},
Type::SpecialForm(special_form) => {
f.set_invalid_syntax();
write!(f.with_type(self.ty), "<special form '{special_form}'>")
write!(f.with_type(self.ty), "<special-form '{special_form}'>")
}
Type::KnownInstance(known_instance) => known_instance
.display_with(self.db, self.settings.clone())
@ -2334,7 +2334,7 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> {
match self.known_instance {
KnownInstanceType::SubscriptedProtocol(generic_context) => {
f.set_invalid_syntax();
f.write_str("<special form '")?;
f.write_str("<special-form '")?;
f.with_type(Type::SpecialForm(SpecialFormType::Protocol))
.write_str("typing.Protocol")?;
generic_context.display(self.db).fmt_detailed(f)?;
@ -2342,7 +2342,7 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> {
}
KnownInstanceType::SubscriptedGeneric(generic_context) => {
f.set_invalid_syntax();
f.write_str("<special form '")?;
f.write_str("<special-form '")?;
f.with_type(Type::SpecialForm(SpecialFormType::Generic))
.write_str("typing.Generic")?;
generic_context.display(self.db).fmt_detailed(f)?;
@ -2398,7 +2398,7 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> {
f.write_char('<')?;
f.with_type(KnownClass::UnionType.to_class_literal(self.db))
.write_str("types.UnionType")?;
f.write_str(" special form")?;
f.write_str(" special-form")?;
if let Ok(ty) = union.union_type(self.db) {
f.write_str(" '")?;
ty.display(self.db).fmt_detailed(f)?;
@ -2408,13 +2408,13 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> {
}
KnownInstanceType::Literal(inner) => {
f.set_invalid_syntax();
f.write_str("<special form '")?;
f.write_str("<special-form '")?;
inner.inner(self.db).display(self.db).fmt_detailed(f)?;
f.write_str("'>")
}
KnownInstanceType::Annotated(inner) => {
f.set_invalid_syntax();
f.write_str("<special form '")?;
f.write_str("<special-form '")?;
f.with_type(Type::SpecialForm(SpecialFormType::Annotated))
.write_str("typing.Annotated")?;
f.write_char('[')?;
@ -2426,13 +2426,13 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> {
f.write_char('<')?;
f.with_type(Type::SpecialForm(SpecialFormType::Callable))
.write_str("typing.Callable")?;
f.write_str(" special form '")?;
f.write_str(" special-form '")?;
callable.display(self.db).fmt_detailed(f)?;
f.write_str("'>")
}
KnownInstanceType::TypeGenericAlias(inner) => {
f.set_invalid_syntax();
f.write_str("<special form '")?;
f.write_str("<special-form '")?;
f.with_type(KnownClass::Type.to_class_literal(self.db))
.write_str("type")?;
f.write_char('[')?;

View File

@ -990,7 +990,7 @@ discord/ext/commands/converter.py:267: error: Incompatible types in assignment (
discord/ext/commands/converter.py:379: error: Incompatible return value type (got "Tuple[Union[Guild, int, None], int, int]", expected "Tuple[Optional[int], int, int]") [return-value]
discord/ext/commands/converter.py:483: error: Name "result" already defined on line 476 [no-redef]
discord/ext/commands/converter.py:517: error: Name "result" already defined on line 510 [no-redef]
discord/ext/commands/converter.py:1280: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo" [arg-type]
discord/ext/commands/converter.py:1280: error: Argument 2 to "issubclass" has incompatible type "<typing special-form>"; expected "_ClassInfo" [arg-type]
discord/ext/commands/converter.py:1413: error: Need type annotation for "conversions" (hint: "conversions: Dict[<type>, <type>] = ...") [var-annotated]
discord/ext/commands/parameters.py:63: error: Parameter 1 of Literal[...] is invalid [valid-type]
discord/ext/commands/parameters.py:64: error: Parameter 1 of Literal[...] is invalid [valid-type]

View File

@ -123,8 +123,8 @@ discord/ext/commands/bot.py:330:50: error[invalid-type-arguments] Too many type
discord/ext/commands/bot.py:655:16: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__name__`
discord/ext/commands/bot.py:681:16: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__name__`
discord/ext/commands/bot.py:1546:13: error[invalid-parameter-default] Default value of type `_DefaultRepr` is not assignable to annotated parameter type `HelpCommand | None`
discord/ext/commands/cog.py:288:36: error[invalid-type-arguments] Type `<special form 'typing.Self'>` is not assignable to upper bound `Cog | None` of type variable `CogT@Command`
discord/ext/commands/cog.py:289:79: error[invalid-type-arguments] Type `<special form 'typing.Self'>` is not assignable to upper bound `Group | Cog` of type variable `GroupT@Command`
discord/ext/commands/cog.py:288:36: error[invalid-type-arguments] Type `<special-form 'typing.Self'>` is not assignable to upper bound `Cog | None` of type variable `CogT@Command`
discord/ext/commands/cog.py:289:79: error[invalid-type-arguments] Type `<special-form 'typing.Self'>` is not assignable to upper bound `Group | Cog` of type variable `GroupT@Command`
discord/ext/commands/context.py:411:15: error[invalid-method-override] Invalid override of method `_get_channel`: Definition is incompatible with `Messageable._get_channel`
discord/ext/commands/context.py:783:9: error[invalid-method-override] Invalid override of method `typing`: Definition is incompatible with `Messageable.typing`
discord/ext/commands/converter.py:402:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `TextChannel | VoiceChannel | StageChannel | ... omitted 4 union elements`, found `(VoiceChannel & ~AlwaysFalsy) | (StageChannel & ~AlwaysFalsy) | (ForumChannel & Messageable & ~AlwaysFalsy) | ... omitted 5 union elements`
@ -312,7 +312,7 @@ discord/sticker.py:434:16: warning[possibly-missing-attribute] Attribute `_get_g
discord/sticker.py:489:43: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]`
discord/sticker.py:490:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]`
discord/sticker.py:511:15: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]`
discord/ui/action_row.py:122:67: error[invalid-type-arguments] Type `<special form 'typing.Self'>` is not assignable to upper bound `BaseView | ActionRow[Unknown] | Container[Unknown]` of type variable `C@ContainedItemCallbackType`
discord/ui/action_row.py:122:67: error[invalid-type-arguments] Type `<special-form 'typing.Self'>` is not assignable to upper bound `BaseView | ActionRow[Unknown] | Container[Unknown]` of type variable `C@ContainedItemCallbackType`
discord/ui/action_row.py:163:26: error[unresolved-attribute] Object of type `(Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]` has no attribute `__discord_ui_model_type__`
discord/ui/action_row.py:163:59: error[unresolved-attribute] Object of type `(Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]` has no attribute `__discord_ui_model_kwargs__`
discord/ui/action_row.py:166:27: error[unresolved-attribute] Object of type `(Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]` has no attribute `__name__`
@ -328,7 +328,7 @@ discord/ui/button.py:276:9: error[invalid-method-override] Invalid override of m
discord/ui/button.py:287:9: error[invalid-method-override] Invalid override of method `_refresh_component`: Definition is incompatible with `Item._refresh_component`
discord/ui/button.py:376:9: error[unresolved-attribute] Unresolved attribute `__discord_ui_model_type__` on type `(S@button, Interaction[Any], Button[V@button], /) -> Coroutine[Any, Any, Any]`.
discord/ui/button.py:377:9: error[unresolved-attribute] Unresolved attribute `__discord_ui_model_kwargs__` on type `(S@button, Interaction[Any], Button[V@button], /) -> Coroutine[Any, Any, Any]`.
discord/ui/container.py:109:77: error[invalid-type-arguments] Type `<special form 'typing.Self'>` is not assignable to upper bound `BaseView | ActionRow[Unknown] | Container[Unknown]` of type variable `C@ContainedItemCallbackType`
discord/ui/container.py:109:77: error[invalid-type-arguments] Type `<special-form 'typing.Self'>` is not assignable to upper bound `BaseView | ActionRow[Unknown] | Container[Unknown]` of type variable `C@ContainedItemCallbackType`
discord/ui/container.py:151:30: error[unresolved-attribute] Object of type `((Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]) & ~Item[object]` has no attribute `__discord_ui_model_type__`
discord/ui/container.py:151:62: error[unresolved-attribute] Object of type `((Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]) & ~Item[object]` has no attribute `__discord_ui_model_kwargs__`
discord/ui/container.py:153:31: error[unresolved-attribute] Object of type `((Unknown, Interaction[Any], Unknown, /) -> Coroutine[Any, Any, Any]) & ~Item[object]` has no attribute `__name__`
@ -343,7 +343,7 @@ discord/ui/file_upload.py:184:9: error[invalid-method-override] Invalid override
discord/ui/label.py:112:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict`
discord/ui/label.py:125:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component`
discord/ui/media_gallery.py:259:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component`
discord/ui/modal.py:109:55: error[invalid-type-arguments] Type `<special form 'typing.Self'>` is not assignable to upper bound `BaseView` of type variable `V@Item`
discord/ui/modal.py:109:55: error[invalid-type-arguments] Type `<special-form 'typing.Self'>` is not assignable to upper bound `BaseView` of type variable `V@Item`
discord/ui/modal.py:159:15: error[invalid-method-override] Invalid override of method `on_error`: Definition is incompatible with `BaseView.on_error`
discord/ui/modal.py:176:9: error[invalid-method-override] Invalid override of method `_refresh`: Definition is incompatible with `BaseView._refresh`
discord/ui/modal.py:202:15: error[invalid-method-override] Invalid override of method `_scheduled_task`: Definition is incompatible with `BaseView._scheduled_task`

View File

@ -3060,8 +3060,8 @@ homeassistant/components/rfxtrx/switch.py:149:36: error[unresolved-attribute] Ob
homeassistant/components/ring/camera.py:186:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader`
homeassistant/components/ring/entity.py:79:54: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@exception_wrap]` has no attribute `__name__`
homeassistant/components/ring/entity.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `RingDevices`, found `Unknown | RingDevices | dict[str, Any]`
homeassistant/components/ring/switch.py:103:38: error[invalid-argument-type] Argument is incorrect: Expected `<special form 'typing.Self'>`, found `RingSwitchEntityDescription[Any]`
homeassistant/components/ring/switch.py:124:57: error[invalid-argument-type] Argument is incorrect: Expected `<special form 'typing.Self'>`, found `RingSwitchEntityDescription[RingDeviceT@RingSwitch]`
homeassistant/components/ring/switch.py:103:38: error[invalid-argument-type] Argument is incorrect: Expected `<special-form 'typing.Self'>`, found `RingSwitchEntityDescription[Any]`
homeassistant/components/ring/switch.py:124:57: error[invalid-argument-type] Argument is incorrect: Expected `<special-form 'typing.Self'>`, found `RingSwitchEntityDescription[RingDeviceT@RingSwitch]`
homeassistant/components/ripple/sensor.py:7:6: error[unresolved-import] Cannot resolve imported module `pyripple`
homeassistant/components/risco/config_flow.py:272:51: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
homeassistant/components/risco/config_flow.py:294:32: warning[possibly-missing-attribute] Attribute `values` may be missing on object of type `Unknown | int | dict[Unknown | str, Unknown | AlarmControlPanelState] | dict[Unknown | AlarmControlPanelState, Unknown | str]`
@ -4122,8 +4122,8 @@ homeassistant/components/yeelight/device.py:200:9: error[invalid-assignment] Obj
homeassistant/components/yeelight/light.py:256:47: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__`
homeassistant/components/yeelight/light.py:264:43: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__`
homeassistant/components/yeelight/light.py:270:43: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__`
homeassistant/components/yeelight/scanner.py:55:13: error[invalid-assignment] Object of type `Self@async_get` is not assignable to attribute `_scanner` of type `<special form 'typing.Self'> | None`
homeassistant/components/yeelight/scanner.py:56:16: error[invalid-return-type] Return type does not match returned value: expected `Self@async_get`, found `<special form 'typing.Self'> | None`
homeassistant/components/yeelight/scanner.py:55:13: error[invalid-assignment] Object of type `Self@async_get` is not assignable to attribute `_scanner` of type `<special-form 'typing.Self'> | None`
homeassistant/components/yeelight/scanner.py:56:16: error[invalid-return-type] Return type does not match returned value: expected `Self@async_get`, found `<special-form 'typing.Self'> | None`
homeassistant/components/yeelightsunflower/light.py:9:8: error[unresolved-import] Cannot resolve imported module `yeelightsunflower`
homeassistant/components/yi/camera.py:7:6: error[unresolved-import] Cannot resolve imported module `aioftp`
homeassistant/components/yi/camera.py:144:34: error[invalid-argument-type] Argument to bound method `open_camera` is incorrect: Expected `str`, found `Unknown | None`

View File

@ -8230,10 +8230,10 @@ torch/_library/infer_schema.py:63:18: error[unresolved-attribute] Object of type
torch/_library/infer_schema.py:132:37: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject`
torch/_library/infer_schema.py:185:50: error[unresolved-attribute] Module `torch` has no member `device`
torch/_library/infer_schema.py:187:44: error[unresolved-attribute] Module `torch` has no member `dtype`
torch/_library/infer_schema.py:222:80: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm | GenericAlias, str] | tuple[<types.UnionType special form>, str]]` is not assignable to `list[tuple[type | _SpecialForm | GenericAlias, str]]`
torch/_library/infer_schema.py:244:46: error[invalid-argument-type] Argument to function `derived_seq_types` is incorrect: Expected `type | _SpecialForm`, found `<types.UnionType special form>`
torch/_library/infer_schema.py:248:13: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[tuple[type | _SpecialForm | GenericAlias, str]]`, found `GeneratorType[tuple[<types.UnionType special form 'Unknown | None'>, str], None, None]`
torch/_library/infer_schema.py:256:82: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm, str, bool, bool, bool] | tuple[<types.UnionType special form 'int | float'>, str, bool, bool, bool] | tuple[<NewType pseudo-class 'OpaqueType'>, str, bool, bool, bool]]` is not assignable to `list[tuple[type | _SpecialForm, str, bool, bool, bool]]`
torch/_library/infer_schema.py:222:80: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm | GenericAlias, str] | tuple[<types.UnionType special-form>, str]]` is not assignable to `list[tuple[type | _SpecialForm | GenericAlias, str]]`
torch/_library/infer_schema.py:244:46: error[invalid-argument-type] Argument to function `derived_seq_types` is incorrect: Expected `type | _SpecialForm`, found `<types.UnionType special-form>`
torch/_library/infer_schema.py:248:13: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[tuple[type | _SpecialForm | GenericAlias, str]]`, found `GeneratorType[tuple[<types.UnionType special-form 'Unknown | None'>, str], None, None]`
torch/_library/infer_schema.py:256:82: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm, str, bool, bool, bool] | tuple[<types.UnionType special-form 'int | float'>, str, bool, bool, bool] | tuple[<NewType pseudo-class 'OpaqueType'>, str, bool, bool, bool]]` is not assignable to `list[tuple[type | _SpecialForm, str, bool, bool, bool]]`
torch/_library/opaque_object.py:23:36: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject`
torch/_library/opaque_object.py:26:41: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject`
torch/_library/opaque_object.py:84:12: error[unresolved-attribute] Module `torch._C` has no member `_make_opaque_object`
@ -24835,14 +24835,14 @@ torch/utils/_pytree.py:1119:30: error[unresolved-attribute] Special form `typing
torch/utils/_pytree.py:1120:31: error[unresolved-attribute] Special form `typing.Self` has no attribute `num_leaves`
torch/utils/_pytree.py:1131:62: error[too-many-positional-arguments] Too many positional arguments to bound method `__repr__`: expected 1, got 2
torch/utils/_pytree.py:1135:58: error[too-many-positional-arguments] Too many positional arguments to bound method `__repr__`: expected 1, got 2
torch/utils/_pytree.py:1167:16: error[invalid-return-type] Return type does not match returned value: expected `list[Self@children_specs]`, found `list[<special form 'typing.Self'>]`
torch/utils/_pytree.py:1173:16: error[invalid-return-type] Return type does not match returned value: expected `list[Self@children]`, found `list[<special form 'typing.Self'>]`
torch/utils/_pytree.py:1176:16: error[invalid-return-type] Return type does not match returned value: expected `Self@child`, found `<special form 'typing.Self'>`
torch/utils/_pytree.py:1167:16: error[invalid-return-type] Return type does not match returned value: expected `list[Self@children_specs]`, found `list[<special-form 'typing.Self'>]`
torch/utils/_pytree.py:1173:16: error[invalid-return-type] Return type does not match returned value: expected `list[Self@children]`, found `list[<special-form 'typing.Self'>]`
torch/utils/_pytree.py:1176:16: error[invalid-return-type] Return type does not match returned value: expected `Self@child`, found `<special-form 'typing.Self'>`
torch/utils/_pytree.py:1280:20: error[unresolved-attribute] Special form `typing.Self` has no attribute `num_leaves`
torch/utils/_pytree.py:1281:34: error[unresolved-attribute] Special form `typing.Self` has no attribute `unflatten`
torch/utils/_pytree.py:1341:18: warning[deprecated] The class `LeafSpec` is deprecated: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
torch/utils/_pytree.py:1344:24: warning[deprecated] The class `LeafSpec` is deprecated: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead.
torch/utils/_pytree.py:1917:40: error[invalid-argument-type] Argument to function `_treespec_to_json` is incorrect: Expected `TreeSpec`, found `<special form 'typing.Self'>`
torch/utils/_pytree.py:1917:40: error[invalid-argument-type] Argument to function `_treespec_to_json` is incorrect: Expected `TreeSpec`, found `<special-form 'typing.Self'>`
torch/utils/_stats.py:26:12: error[unresolved-attribute] Object of type `(**_P@count) -> _R@count` has no attribute `__qualname__`
torch/utils/_stats.py:27:33: error[unresolved-attribute] Object of type `(**_P@count) -> _R@count` has no attribute `__qualname__`
torch/utils/_stats.py:28:29: error[unresolved-attribute] Object of type `(**_P@count) -> _R@count` has no attribute `__qualname__`