mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-21 15:52:34 +00:00
[ty] Sync vendored typeshed stubs (#20876)
Close and reopen this PR to trigger CI --------- Co-authored-by: typeshedbot <> Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
parent
651f7963a7
commit
cafb96aa7a
27 changed files with 487 additions and 288 deletions
|
@ -2189,7 +2189,7 @@ All attribute access on literal `bytes` types is currently delegated to `builtin
|
|||
```py
|
||||
# revealed: bound method Literal[b"foo"].join(iterable_of_bytes: Iterable[@Todo(Support for `typing.TypeAlias`)], /) -> bytes
|
||||
reveal_type(b"foo".join)
|
||||
# revealed: bound method Literal[b"foo"].endswith(suffix: @Todo(Support for `typing.TypeAlias`) | tuple[@Todo(Support for `typing.TypeAlias`), ...], start: SupportsIndex | None = EllipsisType, end: SupportsIndex | None = EllipsisType, /) -> bool
|
||||
# revealed: bound method Literal[b"foo"].endswith(suffix: @Todo(Support for `typing.TypeAlias`) | tuple[@Todo(Support for `typing.TypeAlias`), ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> bool
|
||||
reveal_type(b"foo".endswith)
|
||||
```
|
||||
|
||||
|
|
|
@ -30,3 +30,27 @@ class B: ...
|
|||
# error: "Operator `|` is unsupported between objects of type `<class 'A'>` and `<class 'B'>`"
|
||||
reveal_type(A | B) # revealed: Unknown
|
||||
```
|
||||
|
||||
## Other binary operations resulting in `UnionType`
|
||||
|
||||
```toml
|
||||
[environment]
|
||||
python-version = "3.12"
|
||||
```
|
||||
|
||||
```py
|
||||
class A: ...
|
||||
class B: ...
|
||||
|
||||
def _(sub_a: type[A], sub_b: type[B]):
|
||||
reveal_type(A | sub_b) # revealed: UnionType
|
||||
reveal_type(sub_a | B) # revealed: UnionType
|
||||
reveal_type(sub_a | sub_b) # revealed: UnionType
|
||||
|
||||
class C[T]: ...
|
||||
class D[T]: ...
|
||||
|
||||
reveal_type(C | D) # revealed: UnionType
|
||||
|
||||
reveal_type(C[int] | D[str]) # revealed: UnionType
|
||||
```
|
||||
|
|
|
@ -651,7 +651,7 @@ static_assert(is_assignable_to(TypeOf[property.__set__], Callable))
|
|||
reveal_type(MyClass.my_property.__set__)
|
||||
static_assert(is_assignable_to(TypeOf[MyClass.my_property.__set__], Callable))
|
||||
|
||||
# revealed: def startswith(self, prefix: str | tuple[str, ...], start: SupportsIndex | None = EllipsisType, end: SupportsIndex | None = EllipsisType, /) -> bool
|
||||
# revealed: def startswith(self, prefix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> bool
|
||||
reveal_type(str.startswith)
|
||||
static_assert(is_assignable_to(TypeOf[str.startswith], Callable))
|
||||
|
||||
|
@ -689,7 +689,7 @@ def _(
|
|||
# revealed: (obj: type) -> None
|
||||
reveal_type(e)
|
||||
|
||||
# revealed: (fget: ((Any, /) -> Any) | None = EllipsisType, fset: ((Any, Any, /) -> None) | None = EllipsisType, fdel: ((Any, /) -> None) | None = EllipsisType, doc: str | None = EllipsisType) -> property
|
||||
# revealed: (fget: ((Any, /) -> Any) | None = None, fset: ((Any, Any, /) -> None) | None = None, fdel: ((Any, /) -> None) | None = None, doc: str | None = None) -> property
|
||||
reveal_type(f)
|
||||
|
||||
# revealed: Overload[(self: property, instance: None, owner: type, /) -> Unknown, (self: property, instance: object, owner: type | None = None, /) -> Unknown]
|
||||
|
@ -707,7 +707,7 @@ def _(
|
|||
# revealed: (instance: object, value: object, /) -> Unknown
|
||||
reveal_type(j)
|
||||
|
||||
# revealed: (self, prefix: str | tuple[str, ...], start: SupportsIndex | None = EllipsisType, end: SupportsIndex | None = EllipsisType, /) -> bool
|
||||
# revealed: (self, prefix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> bool
|
||||
reveal_type(k)
|
||||
|
||||
# revealed: (prefix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> bool
|
||||
|
|
|
@ -26,13 +26,13 @@ error[invalid-await]: `Literal[1]` is not awaitable
|
|||
2 | await 1 # error: [invalid-await]
|
||||
| ^
|
||||
|
|
||||
::: stdlib/builtins.pyi:344:7
|
||||
::: stdlib/builtins.pyi:346:7
|
||||
|
|
||||
343 | @disjoint_base
|
||||
344 | class int:
|
||||
345 | @disjoint_base
|
||||
346 | class int:
|
||||
| --- type defined here
|
||||
345 | """int([x]) -> integer
|
||||
346 | int(x, base=10) -> integer
|
||||
347 | """int([x]) -> integer
|
||||
348 | int(x, base=10) -> integer
|
||||
|
|
||||
info: `__await__` is missing
|
||||
info: rule `invalid-await` is enabled by default
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue