Skip to content

Commit

Permalink
Updated typeshed stubs to the latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictraut committed Oct 19, 2024
1 parent 235dbcb commit 80d24c8
Show file tree
Hide file tree
Showing 459 changed files with 3,515 additions and 5,145 deletions.
9 changes: 7 additions & 2 deletions packages/pyright-internal/src/tests/samples/subscript1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
def func1(
a1: Queue[int],
b1: OrderedDict[str, str],
c1: Future[int],
d1: list[int],
e1: dict[str, int],
f1: set[int],
g1: deque[int],
h1: frozenset[int],
# These previously generated errors, but no longer do because of
# changes in the typeshed stubs.
c1: Future[int],
i1: Task[None],
) -> None:
pass
Expand All @@ -41,12 +43,15 @@ def func2(
class A:
a1: Queue[int] = Queue()
b1: OrderedDict[str, str] = OrderedDict()
c1: Future[int] = Future()
d1: list[int] = []
e1: dict[str, int] = {}
f1: set[int] = set()
g1: deque[int] = deque()
h1: frozenset[int] = frozenset()

# These previously generated errors, but no longer do because of
# changes in the typeshed stubs.
c1: Future[int] = Future()
i1: Task[None]


Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/tests/typeEvaluator6.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ test('Subscript1', () => {
// Analyze with Python 3.8 settings.
configOptions.defaultPythonVersion = pythonVersion3_8;
const analysisResults38 = TestUtils.typeAnalyzeSampleFiles(['subscript1.py'], configOptions);
TestUtils.validateResults(analysisResults38, 18);
TestUtils.validateResults(analysisResults38, 14);

// Analyze with Python 3.8 settings.
configOptions.defaultPythonVersion = pythonVersion3_10;
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/typeshed-fallback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the project the stubs are for, but instead report them here to typeshed.**
Further documentation on stub files, typeshed, and Python's typing system in
general, can also be found at https://typing.readthedocs.io/en/latest/.

Typeshed supports Python versions 3.8 and up.
Typeshed supports Python versions 3.8 to 3.13.

## Using

Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/typeshed-fallback/commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dbd0d3521745288a3b2e345d8683bb9539d28d60
b0d57cc03c83e6e75a7b9cf13fb89b06c5fa039f
2 changes: 2 additions & 0 deletions packages/pyright-internal/typeshed-fallback/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
__future__: 3.0-
__main__: 3.0-
_ast: 3.0-
_asyncio: 3.0-
_bisect: 3.0-
_bootlocale: 3.4-3.9
_codecs: 3.0-
Expand All @@ -37,6 +38,7 @@ _imp: 3.0-
_interpchannels: 3.13-
_interpqueues: 3.13-
_interpreters: 3.13-
_io: 3.0-
_json: 3.0-
_locale: 3.0-
_lsprof: 3.0-
Expand Down
120 changes: 120 additions & 0 deletions packages/pyright-internal/typeshed-fallback/stdlib/_asyncio.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import sys
from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Coroutine, Generator
from contextvars import Context
from types import FrameType
from typing import Any, Literal, TextIO, TypeVar
from typing_extensions import Self, TypeAlias

if sys.version_info >= (3, 9):
from types import GenericAlias

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_TaskYieldType: TypeAlias = Future[object] | None

class Future(Awaitable[_T]):
_state: str
@property
def _exception(self) -> BaseException | None: ...
_blocking: bool
@property
def _log_traceback(self) -> bool: ...
@_log_traceback.setter
def _log_traceback(self, val: Literal[False]) -> None: ...
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __del__(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
@property
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...

def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> BaseException | None: ...
def remove_done_callback(self, fn: Callable[[Self], object], /) -> int: ...
def set_result(self, result: _T, /) -> None: ...
def set_exception(self, exception: type | BaseException, /) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
def _loop(self) -> AbstractEventLoop: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
elif sys.version_info >= (3, 9):
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]

# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass,
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
# and `asyncio.Task.set_result()` always raises.
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
if sys.version_info >= (3, 12):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
eager_start: bool = False,
) -> None: ...
elif sys.version_info >= (3, 11):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
) -> None: ...
else:
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
) -> None: ...

if sys.version_info >= (3, 12):
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
else:
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...

def get_name(self) -> str: ...
def set_name(self, value: object, /) -> None: ...
if sys.version_info >= (3, 12):
def get_context(self) -> Context: ...

def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

def get_event_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def _register_task(task: Task[Any]) -> None: ...
def _unregister_task(task: Task[Any]) -> None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...

if sys.version_info >= (3, 12):
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
3 changes: 2 additions & 1 deletion packages/pyright-internal/typeshed-fallback/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import csv
import sys
from _typeshed import SupportsWrite
from collections.abc import Iterable, Iterator
Expand All @@ -20,7 +21,7 @@ _QuotingType: TypeAlias = int

class Error(Exception): ...

_DialectLike: TypeAlias = str | Dialect | type[Dialect]
_DialectLike: TypeAlias = str | Dialect | csv.Dialect | type[Dialect | csv.Dialect]

class Dialect:
delimiter: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import Self, TypeAlias

Expand Down Expand Up @@ -99,6 +99,9 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]):
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ...

@overload
def POINTER(type: None, /) -> type[c_void_p]: ...
@overload
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...

Expand Down
Loading

0 comments on commit 80d24c8

Please sign in to comment.