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
msfterictraut committed Aug 31, 2021
1 parent 4cb24cb commit dabafb2
Show file tree
Hide file tree
Showing 86 changed files with 1,473 additions and 704 deletions.
5 changes: 0 additions & 5 deletions packages/pyright-internal/src/tests/samples/dunderAll1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# pyright: reportMissingModuleSource=false

from typing import Any
import mock

test = 3
hello = 3
Expand All @@ -17,8 +16,6 @@
__all__.extend(["foo"])
__all__.remove("foo")
__all__ += ["bar"]
__all__ += mock.__all__
__all__.extend(mock.__all__)


my_string = "foo"
Expand All @@ -32,6 +29,4 @@
__all__.extend([my_string])
__all__.remove(my_string)
__all__ += [my_string]
__all__ += mock.AsyncMock
__all__.extend(mock.AsyncMock)
__all__.something()
4 changes: 2 additions & 2 deletions packages/pyright-internal/src/tests/typeEvaluator4.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ test('DunderAll1', () => {

// By default, reportUnsupportedDunderAll is a warning.
let analysisResults = TestUtils.typeAnalyzeSampleFiles(['dunderAll1.py'], configOptions);
TestUtils.validateResults(analysisResults, 0, 9);
TestUtils.validateResults(analysisResults, 0, 7);

// Turn on error.
configOptions.diagnosticRuleSet.reportUnsupportedDunderAll = 'error';
analysisResults = TestUtils.typeAnalyzeSampleFiles(['dunderAll1.py'], configOptions);
TestUtils.validateResults(analysisResults, 9, 0);
TestUtils.validateResults(analysisResults, 7, 0);

// Turn off diagnostic.
configOptions.diagnosticRuleSet.reportUnsupportedDunderAll = 'none';
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 @@
3ce5502675d3c23394b592f00234fbdfc743a7d5
d4f07254526840102f02f7f968b2e5a473b45c33
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if sys.version_info >= (3, 7):
def buffer_updated(self, nbytes: int) -> None: ...

class DatagramProtocol(BaseProtocol):
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore
def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: ...
def error_received(self, exc: Exception) -> None: ...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class UserString(Sequence[str]):
def __len__(self) -> int: ...
# It should return a str to implement Sequence correctly, but it doesn't.
def __getitem__(self: _UserStringT, i: int | slice) -> _UserStringT: ... # type: ignore
def __iter__(self: _UserStringT) -> Iterator[_UserStringT]: ... # type: ignore
def __reversed__(self: _UserStringT) -> Iterator[_UserStringT]: ... # type: ignore
def __add__(self: _UserStringT, other: object) -> _UserStringT: ...
def __mul__(self: _UserStringT, n: int) -> _UserStringT: ...
def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ...
def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ...
def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ...
def clear_extension_cache() -> None: ...

dispatch_table: dict[type, Callable[[type], str | _Reduce[type]]] # undocumented
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Message:
def get_charset(self) -> _CharsetType: ...
def __len__(self) -> int: ...
def __contains__(self, name: str) -> bool: ...
def __iter__(self) -> Iterator[str]: ...
def __getitem__(self, name: str) -> _HeaderType: ...
def __setitem__(self, name: str, val: _HeaderType) -> None: ...
def __delitem__(self, name: str) -> None: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import importlib.machinery
import types
from _typeshed import StrOrBytesPath
from typing import Any, Callable
from typing_extensions import ParamSpec

def module_for_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
def set_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
def set_package(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
_P = ParamSpec("_P")

def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... # type: ignore
def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... # type: ignore
def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ... # type: ignore
def resolve_name(name: str, package: str | None) -> str: ...

MAGIC_NUMBER: bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,17 @@ class LogRecord:
) -> None: ...
def getMessage(self) -> str: ...

class LoggerAdapter:
logger: Logger | LoggerAdapter
_L = TypeVar("_L", Logger, LoggerAdapter[Logger], LoggerAdapter[Any])

class LoggerAdapter(Generic[_L]):
logger: _L
manager: Manager # undocumented
if sys.version_info >= (3, 10):
extra: Mapping[str, Any] | None
def __init__(self, logger: Logger | LoggerAdapter, extra: Mapping[str, Any] | None) -> None: ...
def __init__(self, logger: _L, extra: Mapping[str, Any] | None) -> None: ...
else:
extra: Mapping[str, Any]
def __init__(self, logger: Logger | LoggerAdapter, extra: Mapping[str, Any]) -> None: ...
def __init__(self, logger: _L, extra: Mapping[str, Any]) -> None: ...
def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> tuple[Any, MutableMapping[str, Any]]: ...
if sys.version_info >= (3, 8):
def debug(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import Self
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar
from typing import Any, Callable, ContextManager, Dict, Generic, Iterable, Iterator, List, Mapping, TypeVar

if sys.version_info >= (3, 9):
from types import GenericAlias
Expand All @@ -10,12 +10,17 @@ _S = TypeVar("_S")
_T = TypeVar("_T")

class ApplyResult(Generic[_T]):
def __init__(
self,
pool: Pool,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> None: ...
if sys.version_info >= (3, 8):
def __init__(
self, pool: Pool, callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None
) -> None: ...
else:
def __init__(
self,
cache: Dict[int, ApplyResult[Any]],
callback: Callable[[_T], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...
def get(self, timeout: float | None = ...) -> _T: ...
def wait(self, timeout: float | None = ...) -> None: ...
def ready(self) -> bool: ...
Expand All @@ -26,9 +31,31 @@ class ApplyResult(Generic[_T]):
# alias created during issue #17805
AsyncResult = ApplyResult

class MapResult(ApplyResult[List[_T]]): ...
class MapResult(ApplyResult[List[_T]]):
if sys.version_info >= (3, 8):
def __init__(
self,
pool: Pool,
chunksize: int,
length: int,
callback: Callable[[List[_T]], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...
else:
def __init__(
self,
cache: Dict[int, ApplyResult[Any]],
chunksize: int,
length: int,
callback: Callable[[List[_T]], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...

class IMapIterator(Iterator[_T]):
if sys.version_info >= (3, 8):
def __init__(self, pool: Pool) -> None: ...
else:
def __init__(self, cache: Dict[int, IMapIterator[Any]]) -> None: ...
def __iter__(self: _S) -> _S: ...
def next(self, timeout: float | None = ...) -> _T: ...
def __next__(self, timeout: float | None = ...) -> _T: ...
Expand Down
6 changes: 6 additions & 0 deletions packages/pyright-internal/typeshed-fallback/stdlib/stat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def S_ISLNK(mode: int) -> bool: ...
def S_ISSOCK(mode: int) -> bool: ...
def S_IMODE(mode: int) -> int: ...
def S_IFMT(mode: int) -> int: ...
def S_ISDOOR(mode: int) -> int: ...
def S_ISPORT(mode: int) -> int: ...
def S_ISWHT(mode: int) -> int: ...
def filemode(mode: int) -> str: ...

ST_MODE: int
Expand All @@ -29,6 +32,9 @@ S_IFBLK: int
S_IFDIR: int
S_IFCHR: int
S_IFIFO: int
S_IFDOOR: int
S_IFPORT: int
S_IFWHT: int
S_ISUID: int
S_ISGID: int
S_ISVTX: int
Expand Down
9 changes: 5 additions & 4 deletions packages/pyright-internal/typeshed-fallback/stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986
import sys
from abc import ABCMeta, abstractmethod
from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
from typing_extensions import Literal as _Literal
from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec

if sys.version_info >= (3, 7):
from types import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType
Expand Down Expand Up @@ -36,6 +36,8 @@ class _SpecialForm:
def __getitem__(self, typeargs: Any) -> object: ...

_F = TypeVar("_F", bound=Callable[..., Any])
_P = _ParamSpec("_P")
_T = TypeVar("_T")

def overload(func: _F) -> _F: ...

Expand All @@ -50,7 +52,7 @@ Type: _SpecialForm = ...
ClassVar: _SpecialForm = ...
if sys.version_info >= (3, 8):
Final: _SpecialForm = ...
def final(f: _F) -> _F: ...
def final(f: _T) -> _T: ...
Literal: _SpecialForm = ...
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
Expand Down Expand Up @@ -87,7 +89,6 @@ if sys.version_info >= (3, 10):
NoReturn = Union[None]

# These type variables are used by the container types.
_T = TypeVar("_T")
_S = TypeVar("_S")
_KT = TypeVar("_KT") # Key type.
_VT = TypeVar("_VT") # Value type.
Expand All @@ -99,7 +100,7 @@ _T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant.
_TC = TypeVar("_TC", bound=Type[object])

def no_type_check(arg: _F) -> _F: ...
def no_type_check_decorator(decorator: _F) -> _F: ...
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore

# Type aliases and type constructors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import io
import sys
from _typeshed import Self, StrPath
from os import PathLike
from types import TracebackType
from typing import IO, Callable, Iterable, Iterator, Protocol, Sequence, Tuple, Type, overload
from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Tuple, Type, overload
from typing_extensions import Literal

_DateTuple = Tuple[int, int, int, int, int, int]
Expand Down Expand Up @@ -212,9 +213,12 @@ if sys.version_info >= (3, 8):
def name(self) -> str: ...
@property
def parent(self) -> Path: ... # undocumented
if sys.version_info >= (3, 10):
@property
def filename(self) -> PathLike[str]: ...
def __init__(self, root: ZipFile | StrPath | IO[bytes], at: str = ...) -> None: ...
if sys.version_info >= (3, 9):
def open(self, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
def open(self, mode: str = ..., *args: Any, pwd: bytes | None = ..., **kwargs: Any) -> IO[bytes]: ...
else:
@property
def open(self) -> _PathOpenProtocol: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Image:
box: tuple[float, float, float, float] | None = ...,
reducing_gap: float | None = ...,
) -> Image: ...
def reduce(self, factor: int | tuple[int, int] | list[int], box: _Box | None = ...) -> None: ...
def reduce(self, factor: int | tuple[int, int] | list[int], box: _Box | None = ...) -> Image: ...
def rotate(
self,
angle: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ from _typeshed import SupportsRead
from typing import IO, Any, Mapping, Sequence, Text, Union

from yaml.constructor import BaseConstructor, Constructor, SafeConstructor
from yaml.events import Event
from yaml.nodes import Node
from yaml.representer import BaseRepresenter, Representer, SafeRepresenter
from yaml.resolver import BaseResolver, Resolver
from yaml.serializer import Serializer
from yaml.tokens import Token

_Readable = SupportsRead[Union[Text, bytes]]

class CParser:
def __init__(self, stream: str | bytes | _Readable) -> None: ...
def dispose(self) -> None: ...
def get_token(self) -> Token | None: ...
def peek_token(self) -> Token | None: ...
def check_token(self, *choices) -> bool: ...
def get_event(self) -> Event | None: ...
def peek_event(self) -> Event | None: ...
def check_event(self, *choices) -> bool: ...
def check_node(self) -> bool: ...
def get_node(self) -> Node | None: ...
def get_single_node(self) -> Node | None: ...

class CBaseLoader(CParser, BaseConstructor, BaseResolver):
def __init__(self, stream: str | bytes | _Readable) -> None: ...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "2.8"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .sdk_config import SDKConfig

global_sdk_config: SDKConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .patcher import patch as patch, patch_all as patch_all
from .recorder import AWSXRayRecorder as AWSXRayRecorder

xray_recorder: AWSXRayRecorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Any

from .context import Context as _Context

class AsyncContext(_Context):
def __init__(self, *args, loop: Any | None = ..., use_task_factory: bool = ..., **kwargs) -> None: ...
def clear_trace_entities(self) -> None: ...

class TaskLocalStorage:
def __init__(self, loop: Any | None = ...) -> None: ...
def __setattr__(self, name, value) -> None: ...
def __getattribute__(self, item): ...
def clear(self) -> None: ...

def task_factory(loop, coro): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any

from .models.segment import SegmentContextManager as SegmentContextManager
from .models.subsegment import (
SubsegmentContextManager as SubsegmentContextManager,
is_already_recording as is_already_recording,
subsegment_decorator as subsegment_decorator,
)
from .recorder import AWSXRayRecorder as AWSXRayRecorder
from .utils import stacktrace as stacktrace

class AsyncSegmentContextManager(SegmentContextManager):
async def __aenter__(self): ...
async def __aexit__(self, exc_type, exc_val, exc_tb): ...

class AsyncSubsegmentContextManager(SubsegmentContextManager):
async def __call__(self, wrapped, instance, args, kwargs): ...
async def __aenter__(self): ...
async def __aexit__(self, exc_type, exc_val, exc_tb): ...

class AsyncAWSXRayRecorder(AWSXRayRecorder):
def capture_async(self, name: Any | None = ...): ...
def in_segment_async(self, name: Any | None = ..., **segment_kwargs): ...
def in_subsegment_async(self, name: Any | None = ..., **subsegment_kwargs): ...
async def record_subsegment_async(self, wrapped, instance, args, kwargs, name, namespace, meta_processor): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import time
from logging import Logger
from typing import Any

from .. import global_sdk_config as global_sdk_config
from .exceptions.exceptions import SegmentNotFoundException as SegmentNotFoundException
from .models.dummy_entities import DummySegment as DummySegment
from .models.entity import Entity
from .models.segment import Segment
from .models.subsegment import Subsegment

log: Logger
SUPPORTED_CONTEXT_MISSING: Any
MISSING_SEGMENT_MSG: str
CXT_MISSING_STRATEGY_KEY: str

class Context:
def __init__(self, context_missing: str = ...) -> None: ...
def put_segment(self, segment: Segment) -> None: ...
def end_segment(self, end_time: time.struct_time | None = ...) -> None: ...
def put_subsegment(self, subsegment: Subsegment) -> None: ...
def end_subsegment(self, end_time: time.struct_time | None = ...): ...
def get_trace_entity(self): ...
def set_trace_entity(self, trace_entity: Entity) -> None: ...
def clear_trace_entities(self) -> None: ...
def handle_context_missing(self) -> None: ...
@property
def context_missing(self): ...
@context_missing.setter
def context_missing(self, value: str) -> None: ...
Loading

0 comments on commit dabafb2

Please sign in to comment.