Skip to content

Commit

Permalink
sync typeshed, prepare release (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Nov 14, 2021
1 parent 57c75bf commit ae70dd4
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 157 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ call ``resolver.get_fully_qualified_name('collections.Set')`` to retrieve the
Changelog
---------

Version 1.1.3 (November 14, 2021)

- Update bundled typeshed
- Declare support for Python 3.10
- Fix undeclared dependency on ``mypy_extensions``

Version 1.1.2 (November 5, 2021)

- Update bundled typeshed
Expand Down
2 changes: 1 addition & 1 deletion typeshed_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
from .resolver import ImportedInfo, Resolver


__version__ = "1.1.2"
__version__ = "1.1.3"
2 changes: 1 addition & 1 deletion typeshed_client/typeshed/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class type(object):
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
def __subclasses__(self: _TT) -> List[_TT]: ...
# Note: the documentation doesnt specify what the return type is, the standard
# Note: the documentation doesn't specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...
def __instancecheck__(self, instance: Any) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion typeshed_client/typeshed/@python2/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class type(object):
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
def __subclasses__(self: _TT) -> List[_TT]: ...
# Note: the documentation doesnt specify what the return type is, the standard
# Note: the documentation doesn't specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...
def __instancecheck__(self, instance: Any) -> bool: ...
Expand Down
275 changes: 159 additions & 116 deletions typeshed_client/typeshed/builtins.pyi

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions typeshed_client/typeshed/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ class _OrderedDictKeysView(_dict_keys[_KT_co, _VT_co], Reversible[_KT_co]):
class _OrderedDictItemsView(_dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...

# The generics are the wrong way around because of a mypy limitation
# https://github.com/python/mypy/issues/11138
class _OrderedDictValuesView(_dict_values[_VT_co, _KT_co], Reversible[_VT_co], Generic[_VT_co, _KT_co]):
class _OrderedDictValuesView(_dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]):
def __reversed__(self) -> Iterator[_VT_co]: ...

class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
Expand All @@ -256,7 +254,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def __reversed__(self) -> Iterator[_KT]: ...
def keys(self) -> _OrderedDictKeysView[_KT, _VT]: ...
def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...
def values(self) -> _OrderedDictValuesView[_VT, _KT]: ...
def values(self) -> _OrderedDictValuesView[_KT, _VT]: ...

class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Callable[[], _VT] | None
Expand Down
11 changes: 10 additions & 1 deletion typeshed_client/typeshed/contextlib.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import Self
from _typeshed import Self, StrOrBytesPath
from types import TracebackType
from typing import (
IO,
Expand All @@ -9,6 +9,7 @@ from typing import (
Awaitable,
Callable,
ContextManager,
Generic,
Iterator,
Optional,
Type,
Expand Down Expand Up @@ -124,3 +125,11 @@ elif sys.version_info >= (3, 7):
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Any) -> None: ...

if sys.version_info >= (3, 11):
_T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=int | StrOrBytesPath)
class chdir(AbstractContextManager[None], Generic[_T_fd_or_any_path]):
path: _T_fd_or_any_path
def __init__(self, path: _T_fd_or_any_path) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *excinfo: object) -> None: ...
2 changes: 1 addition & 1 deletion typeshed_client/typeshed/decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Decimal(object):
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: int) -> Decimal: ...
def __round__(self, __ndigits: int) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = ...) -> Decimal: ...
Expand Down
49 changes: 43 additions & 6 deletions typeshed_client/typeshed/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, S
from types import (
AsyncGeneratorType,
BuiltinFunctionType,
BuiltinMethodType,
CodeType,
CoroutineType,
FrameType,
FunctionType,
GeneratorType,
GetSetDescriptorType,
LambdaType,
MethodType,
ModuleType,
TracebackType,
)
from typing import Any, ClassVar, NamedTuple, Tuple, Type, Union

if sys.version_info >= (3, 7):
from types import ClassMethodDescriptorType, WrapperDescriptorType, MemberDescriptorType, MethodDescriptorType

from typing import Any, ClassVar, NamedTuple, Protocol, Tuple, Type, TypeVar, Union
from typing_extensions import Literal, TypeGuard

#
Expand Down Expand Up @@ -71,17 +78,47 @@ if sys.version_info >= (3, 8):
else:
def isasyncgenfunction(object: object) -> bool: ...

_T_cont = TypeVar("_T_cont", contravariant=True)
_V_cont = TypeVar("_V_cont", contravariant=True)

class _SupportsSet(Protocol[_T_cont, _V_cont]):
def __set__(self, __instance: _T_cont, __value: _V_cont) -> None: ...

class _SupportsDelete(Protocol[_T_cont]):
def __delete__(self, __instance: _T_cont) -> None: ...

def isasyncgen(object: object) -> TypeGuard[AsyncGeneratorType[Any, Any]]: ...
def istraceback(object: object) -> TypeGuard[TracebackType]: ...
def isframe(object: object) -> TypeGuard[FrameType]: ...
def iscode(object: object) -> TypeGuard[CodeType]: ...
def isbuiltin(object: object) -> TypeGuard[BuiltinFunctionType]: ...
def isroutine(object: object) -> bool: ...

if sys.version_info < (3, 7):
def isroutine(
object: object,
) -> TypeGuard[FunctionType | LambdaType | MethodType | BuiltinFunctionType | BuiltinMethodType]: ...
def ismethoddescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...

else:
def isroutine(
object: object,
) -> TypeGuard[
FunctionType
| LambdaType
| MethodType
| BuiltinFunctionType
| BuiltinMethodType
| WrapperDescriptorType
| MethodDescriptorType
| ClassMethodDescriptorType
]: ...
def ismethoddescriptor(object: object) -> TypeGuard[MethodDescriptorType]: ...
def ismemberdescriptor(object: object) -> TypeGuard[MemberDescriptorType]: ...

def isabstract(object: object) -> bool: ...
def ismethoddescriptor(object: object) -> bool: ...
def isdatadescriptor(object: object) -> bool: ...
def isgetsetdescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...
def isgetsetdescriptor(object: object) -> TypeGuard[GetSetDescriptorType]: ...
def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _SupportsDelete[Any]]: ...

#
# Retrieving source code
Expand Down
2 changes: 1 addition & 1 deletion typeshed_client/typeshed/multiprocessing/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _SemaphoreType = synchronize.Semaphore
# multiprocessing.context.BaseContext's methods, so the two signatures should
# be identical (modulo self).

# Sychronization primitives
# Synchronization primitives
_LockLike = Union[synchronize.Lock, synchronize.RLock]
RawValue = context._default_context.RawValue
RawArray = context._default_context.RawArray
Expand Down
2 changes: 1 addition & 1 deletion typeshed_client/typeshed/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class PathLike(Protocol[_AnyStr_co]):
_FdOrAnyPath = Union[int, StrOrBytesPath]

class DirEntry(Generic[AnyStr]):
# This is what the scandir interator yields
# This is what the scandir iterator yields
# The constructor is hidden

name: AnyStr
Expand Down
21 changes: 21 additions & 0 deletions typeshed_client/typeshed/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ SQLITE_CREATE_TEMP_TRIGGER: int
SQLITE_CREATE_TEMP_VIEW: int
SQLITE_CREATE_TRIGGER: int
SQLITE_CREATE_VIEW: int
if sys.version_info >= (3, 7):
SQLITE_CREATE_VTABLE: int
SQLITE_DELETE: int
SQLITE_DENY: int
SQLITE_DETACH: int
Expand All @@ -46,12 +48,31 @@ SQLITE_DROP_TEMP_TRIGGER: int
SQLITE_DROP_TEMP_VIEW: int
SQLITE_DROP_TRIGGER: int
SQLITE_DROP_VIEW: int
if sys.version_info >= (3, 7):
SQLITE_DROP_VTABLE: int
SQLITE_FUNCTION: int
SQLITE_IGNORE: int
SQLITE_INSERT: int
SQLITE_OK: int
if sys.version_info >= (3, 11):
SQLITE_LIMIT_LENGTH: int
SQLITE_LIMIT_SQL_LENGTH: int
SQLITE_LIMIT_COLUMN: int
SQLITE_LIMIT_EXPR_DEPTH: int
SQLITE_LIMIT_COMPOUND_SELECT: int
SQLITE_LIMIT_VDBE_OP: int
SQLITE_LIMIT_FUNCTION_ARG: int
SQLITE_LIMIT_ATTACHED: int
SQLITE_LIMIT_LIKE_PATTERN_LENGTH: int
SQLITE_LIMIT_VARIABLE_NUMBER: int
SQLITE_LIMIT_TRIGGER_DEPTH: int
SQLITE_LIMIT_WORKER_THREADS: int
SQLITE_PRAGMA: int
SQLITE_READ: int
SQLITE_REINDEX: int
if sys.version_info >= (3, 7):
SQLITE_RECURSIVE: int
SQLITE_SAVEPOINT: int
SQLITE_SELECT: int
SQLITE_TRANSACTION: int
SQLITE_UPDATE: int
Expand Down
12 changes: 6 additions & 6 deletions typeshed_client/typeshed/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class Misc:
pad: _ScreenUnits = ...,
uniform: str = ...,
weight: int = ...,
) -> _GridIndexInfo | Any: ... # can be None but annoyying to check
) -> _GridIndexInfo | Any: ... # can be None but annoying to check
columnconfigure = grid_columnconfigure
rowconfigure = grid_rowconfigure
def grid_location(self, x: _ScreenUnits, y: _ScreenUnits) -> tuple[int, int]: ...
Expand Down Expand Up @@ -730,7 +730,7 @@ class Pack:
forget = pack_forget
propagate = Misc.pack_propagate
# commented out to avoid mypy getting confused with multiple
# inheritance and how things get overrided with different things
# inheritance and how things get overridden with different things
# info = pack_info
# pack_propagate = Misc.pack_propagate
# configure = pack_configure
Expand Down Expand Up @@ -774,7 +774,7 @@ class Place:
place = place_configure
info = place_info
# commented out to avoid mypy getting confused with multiple
# inheritance and how things get overrided with different things
# inheritance and how things get overridden with different things
# config = place_configure
# configure = place_configure
# forget = place_forget
Expand Down Expand Up @@ -816,7 +816,7 @@ class Grid:
location = Misc.grid_location
size = Misc.grid_size
# commented out to avoid mypy getting confused with multiple
# inheritance and how things get overrided with different things
# inheritance and how things get overridden with different things
# bbox = Misc.grid_bbox
# grid_bbox = Misc.grid_bbox
# forget = grid_forget
Expand Down Expand Up @@ -954,7 +954,7 @@ class Button(Widget):
state: Literal["normal", "active", "disabled"] = ...,
takefocus: _TakeFocusValue = ...,
text: float | str = ...,
# We allow the textvariable to be any Variable, not necessarly
# We allow the textvariable to be any Variable, not necessarily
# StringVar. This is useful for e.g. a button that displays the value
# of an IntVar.
textvariable: Variable = ...,
Expand Down Expand Up @@ -2960,7 +2960,7 @@ class OptionMenu(Menubutton):
command: Callable[[StringVar], Any] | None = ...,
) -> None: ...
# configure, config, cget are inherited from Menubutton
# destroy and __getitem__ are overrided, signature does not change
# destroy and __getitem__ are overridden, signature does not change

class _Image(Protocol):
tk: _tkinter.TkappType
Expand Down
4 changes: 2 additions & 2 deletions typeshed_client/typeshed/tkinter/ttk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ class LabeledScale(Frame):
compound: Literal["top"] | Literal["bottom"] = ...,
**kw: Any,
) -> None: ...
# destroy is overrided, signature does not change
# destroy is overridden, signature does not change
value: Any

class OptionMenu(Menubutton):
Expand All @@ -1138,5 +1138,5 @@ class OptionMenu(Menubutton):
command: Callable[[tkinter.StringVar], Any] | None = ...,
) -> None: ...
# configure, config, cget, destroy are inherited from Menubutton
# destroy and __setitem__ are overrided, signature does not change
# destroy and __setitem__ are overridden, signature does not change
def set_menu(self, default: Any | None = ..., *values): ...
14 changes: 11 additions & 3 deletions typeshed_client/typeshed/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from typing import (
ValuesView,
overload,
)
from typing_extensions import Literal, final
from typing_extensions import Literal, ParamSpec, final

# Note, all classes "defined" here require special handling.

Expand Down Expand Up @@ -171,7 +171,7 @@ class SimpleNamespace:

class ModuleType:
__name__: str
__file__: str
__file__: str | None
__dict__: dict[str, Any]
__loader__: _LoaderProtocol | None
__package__: str | None
Expand Down Expand Up @@ -370,7 +370,15 @@ def prepare_class(
# Actually a different type, but `property` is special and we want that too.
DynamicClassAttribute = property

def coroutine(func: Callable[..., Any]) -> CoroutineType[Any, Any, Any]: ...
_Fn = TypeVar("_Fn", bound=Callable[..., object])
_R = TypeVar("_R")
_P = ParamSpec("_P")

# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
@overload
def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore
@overload
def coroutine(func: _Fn) -> _Fn: ... # type: ignore

if sys.version_info >= (3, 8):
CellType = _Cell
Expand Down
8 changes: 2 additions & 6 deletions typeshed_client/typeshed/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
ClassVar: _SpecialForm = ...
NoReturn: _SpecialForm = ...
if sys.version_info >= (3, 8):
Final: _SpecialForm = ...
def final(f: _T) -> _T: ...
Expand Down Expand Up @@ -83,11 +84,6 @@ if sys.version_info >= (3, 10):
TypeAlias: _SpecialForm = ...
TypeGuard: _SpecialForm = ...

# Return type that indicates a function does not return.
# This type is equivalent to the None type, but the no-op Union is necessary to
# distinguish the None type from the None value.
NoReturn = Union[None]

# These type variables are used by the container types.
_S = TypeVar("_S")
_KT = TypeVar("_KT") # Key type.
Expand Down Expand Up @@ -167,7 +163,7 @@ class SupportsRound(Protocol[_T_co]):
def __round__(self) -> int: ...
@overload
@abstractmethod
def __round__(self, ndigits: int) -> _T_co: ...
def __round__(self, __ndigits: int) -> _T_co: ...

@runtime_checkable
class Sized(Protocol, metaclass=ABCMeta):
Expand Down
16 changes: 9 additions & 7 deletions typeshed_client/typeshed/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def IntVar(name: str) -> Any: ... # returns a new TypeVar

# Internal mypy fallback type for all typed dicts (does not exist at runtime)
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
__required_keys__: frozenset[str]
__optional_keys__: frozenset[str]
__total__: bool
def copy(self: _T) -> _T: ...
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
# can go through.
Expand All @@ -69,14 +72,13 @@ TypedDict: object = ...

OrderedDict = _Alias()

def get_type_hints(
obj: Callable[..., Any],
globalns: dict[str, Any] | None = ...,
localns: dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> dict[str, Any]: ...

if sys.version_info >= (3, 7):
def get_type_hints(
obj: Callable[..., Any],
globalns: dict[str, Any] | None = ...,
localns: dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> dict[str, Any]: ...
def get_args(tp: Any) -> Tuple[Any, ...]: ...
def get_origin(tp: Any) -> Any | None: ...

Expand Down

0 comments on commit ae70dd4

Please sign in to comment.