Updated typeshed stubs to the latest versions.

This commit is contained in:
Eric Traut 2020-08-04 08:45:23 -07:00
parent 4ece660c28
commit 7c72278a28
16 changed files with 494 additions and 248 deletions

View File

@ -371,7 +371,7 @@ class Formatter:
class Filter:
def __init__(self, name: str = ...) -> None: ...
def filter(self, record: LogRecord) -> int: ...
def filter(self, record: LogRecord) -> bool: ...
class LogRecord:
args: _ArgsType

View File

@ -122,26 +122,34 @@ class DatagramHandler(SocketHandler):
def makeSocket(self) -> SocketType: ... # type: ignore
class SysLogHandler(Handler):
LOG_EMERG: int
LOG_ALERT: int
LOG_CRIT: int
LOG_DEBUG: int
LOG_EMERG: int
LOG_ERR: int
LOG_INFO: int
LOG_NOTICE: int
LOG_WARNING: int
LOG_AUTH: int
LOG_AUTHPRIV: int
LOG_CRON: int
LOG_DAEMON: int
LOG_FTP: int
LOG_NOTICE: int
LOG_INFO: int
LOG_DEBUG: int
LOG_KERN: int
LOG_LPR: int
LOG_MAIL: int
LOG_NEWS: int
LOG_SYSLOG: int
LOG_USER: int
LOG_MAIL: int
LOG_DAEMON: int
LOG_AUTH: int
LOG_SYSLOG: int
LOG_LPR: int
LOG_NEWS: int
LOG_UUCP: int
LOG_CRON: int
LOG_AUTHPRIV: int
LOG_FTP: int
if sys.version_info >= (3, 9):
LOG_NTP: int
LOG_SECURITY: int
LOG_CONSOLE: int
LOG_SOLCRON: int
LOG_LOCAL0: int
LOG_LOCAL1: int
LOG_LOCAL2: int

View File

@ -1,5 +1,5 @@
import sys
from _typeshed import AnyPath
from _typeshed import AnyPath, StrPath
from types import TracebackType
from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type, Union
@ -162,8 +162,8 @@ class TarFile(Iterable[TarInfo]):
if sys.version_info >= (3, 7):
def add(
self,
name: str,
arcname: Optional[str] = ...,
name: StrPath,
arcname: Optional[StrPath] = ...,
recursive: bool = ...,
*,
filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...,
@ -171,8 +171,8 @@ class TarFile(Iterable[TarInfo]):
elif sys.version_info >= (3,):
def add(
self,
name: str,
arcname: Optional[str] = ...,
name: StrPath,
arcname: Optional[StrPath] = ...,
recursive: bool = ...,
exclude: Optional[Callable[[str], bool]] = ...,
*,

View File

@ -212,7 +212,7 @@ class deque(MutableSequence[_T], Generic[_T]):
def extendleft(self, iterable: Iterable[_T]) -> None: ...
def insert(self, i: int, x: _T) -> None: ...
def index(self, x: _T, start: int = ..., stop: int = ...) -> int: ...
def pop(self, i: int = ...) -> _T: ...
def pop(self) -> _T: ... # type: ignore
def popleft(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def reverse(self) -> None: ...

View File

@ -19,7 +19,7 @@ class Policy:
def register_defect(self, obj: Message, defect: MessageDefect) -> None: ...
def header_max_count(self, name: str) -> Optional[int]: ...
@abstractmethod
def header_source_parse(self, sourcelines: List[str]) -> str: ...
def header_source_parse(self, sourcelines: List[str]) -> Tuple[str, str]: ...
@abstractmethod
def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ...
@abstractmethod
@ -30,7 +30,7 @@ class Policy:
def fold_binary(self, name: str, value: str) -> bytes: ...
class Compat32(Policy):
def header_source_parse(self, sourcelines: List[str]) -> str: ...
def header_source_parse(self, sourcelines: List[str]) -> Tuple[str, str]: ...
def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ...
def header_fetch_parse(self, name: str, value: str) -> Union[str, Header]: ... # type: ignore
def fold(self, name: str, value: str) -> str: ...
@ -43,7 +43,7 @@ class EmailPolicy(Policy):
refold_source: str
header_factory: Callable[[str, str], str]
content_manager: ContentManager
def header_source_parse(self, sourcelines: List[str]) -> str: ...
def header_source_parse(self, sourcelines: List[str]) -> Tuple[str, str]: ...
def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ...
def header_fetch_parse(self, name: str, value: str) -> str: ...
def fold(self, name: str, value: str) -> str: ...

View File

@ -2,7 +2,23 @@ import enum
import sys
from collections import OrderedDict
from types import CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
from typing import AbstractSet, Any, Callable, Dict, Generator, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Type, Union
from typing import (
AbstractSet,
Any,
Callable,
ClassVar,
Dict,
Generator,
List,
Mapping,
NamedTuple,
Optional,
Sequence,
Tuple,
Type,
Union,
)
from typing_extensions import Literal
#
# Types and members
@ -107,6 +123,12 @@ class Signature:
# The name is the same as the enum's name in CPython
class _ParameterKind(enum.IntEnum):
POSITIONAL_ONLY: int
POSITIONAL_OR_KEYWORD: int
VAR_POSITIONAL: int
KEYWORD_ONLY: int
VAR_KEYWORD: int
if sys.version_info >= (3, 8):
description: str
@ -118,11 +140,11 @@ class Parameter:
annotation: Any
kind: _ParameterKind
POSITIONAL_ONLY: _ParameterKind = ...
POSITIONAL_OR_KEYWORD: _ParameterKind = ...
VAR_POSITIONAL: _ParameterKind = ...
KEYWORD_ONLY: _ParameterKind = ...
VAR_KEYWORD: _ParameterKind = ...
POSITIONAL_ONLY: ClassVar[Literal[_ParameterKind.POSITIONAL_ONLY]]
POSITIONAL_OR_KEYWORD: ClassVar[Literal[_ParameterKind.POSITIONAL_OR_KEYWORD]]
VAR_POSITIONAL: ClassVar[Literal[_ParameterKind.VAR_POSITIONAL]]
KEYWORD_ONLY: ClassVar[Literal[_ParameterKind.KEYWORD_ONLY]]
VAR_KEYWORD: ClassVar[Literal[_ParameterKind.VAR_KEYWORD]]
def replace(
self, *, name: Optional[str] = ..., kind: Optional[_ParameterKind] = ..., default: Any = ..., annotation: Any = ...
) -> Parameter: ...

View File

@ -8,8 +8,10 @@ _P = TypeVar("_P", bound=PurePath)
if sys.version_info >= (3, 6):
_PurePathBase = os.PathLike[str]
_PathLike = os.PathLike[str]
else:
_PurePathBase = object
_PathLike = PurePath
class PurePath(_PurePathBase):
parts: Tuple[str, ...]
@ -20,23 +22,14 @@ class PurePath(_PurePathBase):
suffix: str
suffixes: List[str]
stem: str
if sys.version_info < (3, 5):
def __init__(self, *pathsegments: str) -> None: ...
elif sys.version_info < (3, 6):
def __new__(cls: Type[_P], *args: Union[str, PurePath]) -> _P: ...
else:
def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]]) -> _P: ...
def __new__(cls: Type[_P], *args: Union[str, _PathLike]) -> _P: ...
def __hash__(self) -> int: ...
def __lt__(self, other: PurePath) -> bool: ...
def __le__(self, other: PurePath) -> bool: ...
def __gt__(self, other: PurePath) -> bool: ...
def __ge__(self, other: PurePath) -> bool: ...
if sys.version_info < (3, 6):
def __truediv__(self: _P, key: Union[str, PurePath]) -> _P: ...
def __rtruediv__(self: _P, key: Union[str, PurePath]) -> _P: ...
else:
def __truediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ...
def __rtruediv__(self: _P, key: Union[str, os.PathLike[str]]) -> _P: ...
def __truediv__(self: _P, key: Union[str, _PathLike]) -> _P: ...
def __rtruediv__(self: _P, key: Union[str, _PathLike]) -> _P: ...
if sys.version_info < (3,):
def __div__(self: _P, key: Union[str, PurePath]) -> _P: ...
def __bytes__(self) -> bytes: ...
@ -47,18 +40,12 @@ class PurePath(_PurePathBase):
if sys.version_info >= (3, 9):
def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ...
def match(self, path_pattern: str) -> bool: ...
if sys.version_info < (3, 6):
def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ...
else:
def relative_to(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ...
def relative_to(self: _P, *other: Union[str, _PathLike]) -> _P: ...
def with_name(self: _P, name: str) -> _P: ...
if sys.version_info >= (3, 9):
def with_stem(self: _P, stem: str) -> _P: ...
def with_suffix(self: _P, suffix: str) -> _P: ...
if sys.version_info < (3, 6):
def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ...
else:
def joinpath(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ...
def joinpath(self: _P, *other: Union[str, _PathLike]) -> _P: ...
@property
def parents(self: _P) -> Sequence[_P]: ...
@property
@ -68,6 +55,7 @@ class PurePosixPath(PurePath): ...
class PureWindowsPath(PurePath): ...
class Path(PurePath):
def __new__(cls: Type[_P], *args: Union[str, _PathLike], **kwargs: Any) -> _P: ...
def __enter__(self) -> Path: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType]
@ -138,20 +126,15 @@ class Path(PurePath):
def unlink(self, missing_ok: bool = ...) -> None: ...
else:
def unlink(self) -> None: ...
if sys.version_info >= (3, 5):
@classmethod
def home(cls: Type[_P]) -> _P: ...
if sys.version_info < (3, 6):
def __new__(cls: Type[_P], *args: Union[str, PurePath], **kwargs: Any) -> _P: ...
else:
def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]], **kwargs: Any) -> _P: ...
def absolute(self: _P) -> _P: ...
def expanduser(self: _P) -> _P: ...
def read_bytes(self) -> bytes: ...
def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ...
def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ...
def write_bytes(self, data: bytes) -> int: ...
def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ...
@classmethod
def home(cls: Type[_P]) -> _P: ...
def absolute(self: _P) -> _P: ...
def expanduser(self: _P) -> _P: ...
def read_bytes(self) -> bytes: ...
def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ...
def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ...
def write_bytes(self, data: bytes) -> int: ...
def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ...
if sys.version_info >= (3, 8):
def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ...

View File

@ -177,7 +177,11 @@ if sys.platform != "win32":
def pthread_kill(__thread_id: int, __signalnum: int) -> None: ...
def pthread_sigmask(__how: int, __mask: Iterable[int]) -> Set[_SIGNUM]: ...
def set_wakeup_fd(fd: int) -> int: ...
if sys.version_info >= (3, 7):
def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ...
else:
def set_wakeup_fd(fd: int) -> int: ...
if sys.platform != "win32":
def setitimer(__which: int, __seconds: float, __interval: float = ...) -> Tuple[float, float]: ...

View File

@ -2,7 +2,8 @@ import sys
from enum import Enum
from tkinter.constants import * # noqa: F403
from types import TracebackType
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload
from typing_extensions import Literal, TypedDict
TclError: Any
wantobjects: Any
@ -12,6 +13,16 @@ READABLE: Any
WRITABLE: Any
EXCEPTION: Any
# If a manual page mentions Tk_GetAnchor or refers to another manual page named
# 'options', then it means this. Note that some ttk widgets have other things
# named 'anchor' with a different set of allowed values.
_Anchor = Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"]
# string must be e.g. '12.34', '12.34c', '12.34i', '12.34m', '12.34p'
# see Tk_GetPixels man page for what each suffix means
# Some ttk widgets also use empty string.
_ScreenUnits = Union[str, float]
if sys.version_info >= (3, 6):
class EventType(str, Enum):
Activate: str = ...
@ -52,7 +63,10 @@ if sys.version_info >= (3, 6):
VirtualEvent: str = ...
Visibility: str = ...
class Event:
# Events considered covariant because you should never assign to event.widget.
_W = TypeVar("_W", covariant=True, bound="Misc")
class Event(Generic[_W]):
serial: int
num: int
focus: bool
@ -73,44 +87,50 @@ class Event:
type: EventType
else:
type: str
widget: Misc
widget: _W
delta: int
def NoDefaultRoot(): ...
_TraceMode = Literal["array", "read", "write", "unset"]
class Variable:
def __init__(self, master: Optional[Any] = ..., value: Optional[Any] = ..., name: Optional[Any] = ...): ...
def __del__(self): ...
def set(self, value): ...
initialize: Any
def get(self): ...
def trace_variable(self, mode, callback): ...
trace: Any
def trace_vdelete(self, mode, cbname): ...
def trace_vinfo(self): ...
def __eq__(self, other): ...
def __init__(self, master: Optional[Misc] = ..., value: Optional[Any] = ..., name: Optional[str] = ...) -> None: ...
def set(self, value: Any) -> None: ...
initialize = set
def get(self) -> Any: ...
if sys.version_info >= (3, 6):
def trace_add(self, mode, callback): ...
def trace_remove(self, mode, cbname) -> None: ...
def trace_info(self): ...
def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], None]) -> str: ...
def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ...
def trace_info(self) -> List[Tuple[Tuple[_TraceMode, ...], str]]: ...
def trace_variable(self, mode, callback): ... # deprecated
def trace_vdelete(self, mode, cbname): ... # deprecated
def trace_vinfo(self): ... # deprecated
trace = trace_variable # deprecated
class StringVar(Variable):
def __init__(self, master: Optional[Any] = ..., value: Optional[Any] = ..., name: Optional[Any] = ...): ...
def get(self): ...
def __init__(self, master: Optional[Misc] = ..., value: Optional[str] = ..., name: Optional[str] = ...) -> None: ...
def set(self, value: str) -> None: ...
initialize = set
def get(self) -> str: ...
class IntVar(Variable):
def __init__(self, master: Optional[Any] = ..., value: Optional[Any] = ..., name: Optional[Any] = ...): ...
def get(self): ...
def __init__(self, master: Optional[Misc] = ..., value: Optional[int] = ..., name: Optional[str] = ...) -> None: ...
def set(self, value: int) -> None: ...
initialize = set
def get(self) -> int: ...
class DoubleVar(Variable):
def __init__(self, master: Optional[Any] = ..., value: Optional[Any] = ..., name: Optional[Any] = ...): ...
def get(self): ...
def __init__(self, master: Optional[Misc] = ..., value: Optional[float] = ..., name: Optional[str] = ...) -> None: ...
def set(self, value: float) -> None: ...
initialize = set
def get(self) -> float: ...
class BooleanVar(Variable):
def __init__(self, master: Optional[Any] = ..., value: Optional[Any] = ..., name: Optional[Any] = ...): ...
def set(self, value): ...
initialize: Any
def get(self): ...
def __init__(self, master: Optional[Misc] = ..., value: Optional[bool] = ..., name: Optional[str] = ...) -> None: ...
def set(self, value: bool) -> None: ...
initialize = set
def get(self) -> bool: ...
def mainloop(n: int = ...): ...
@ -119,6 +139,8 @@ getdouble: Any
def getboolean(s): ...
# This class is the base class of all widgets. Don't use BaseWidget or Widget
# for that because Tk doesn't inherit from Widget or BaseWidget.
class Misc:
def destroy(self): ...
def deletecommand(self, name): ...
@ -222,42 +244,90 @@ class Misc:
def update(self): ...
def update_idletasks(self): ...
def bindtags(self, tagList: Optional[Any] = ...): ...
def bind(self, sequence: Optional[Any] = ..., func: Optional[Any] = ..., add: Optional[Any] = ...): ...
def unbind(self, sequence, funcid: Optional[Any] = ...): ...
def bind_all(self, sequence: Optional[Any] = ..., func: Optional[Any] = ..., add: Optional[Any] = ...): ...
def unbind_all(self, sequence): ...
def bind_class(self, className, sequence: Optional[Any] = ..., func: Optional[Any] = ..., add: Optional[Any] = ...): ...
def unbind_class(self, className, sequence): ...
# bind with isinstance(func, str) doesn't return anything, but all other
# binds do. The default value of func is not str.
@overload
def bind(
self,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Misc]], Optional[Literal["break"]]]] = ...,
add: Optional[bool] = ...,
) -> str: ...
@overload
def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
@overload
def bind(self, *, func: str, add: Optional[bool] = ...) -> None: ...
# There's no way to know what type of widget bind_all and bind_class
# callbacks will get, so those are Misc.
@overload
def bind_all(
self,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Misc]], Optional[Literal["break"]]]] = ...,
add: Optional[bool] = ...,
) -> str: ...
@overload
def bind_all(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
@overload
def bind_all(self, *, func: str, add: Optional[bool] = ...) -> None: ...
@overload
def bind_class(
self,
className: str,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Misc]], Optional[Literal["break"]]]] = ...,
add: Optional[bool] = ...,
) -> str: ...
@overload
def bind_class(self, className: str, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
@overload
def bind_class(self, className: str, *, func: str, add: Optional[bool] = ...) -> None: ...
def unbind(self, sequence: str, funcid: Optional[str] = ...) -> None: ...
def unbind_all(self, sequence: str) -> None: ...
def unbind_class(self, className: str, sequence: str) -> None: ...
def mainloop(self, n: int = ...): ...
def quit(self): ...
def nametowidget(self, name): ...
register: Any
def configure(self, cnf: Optional[Any] = ..., **kw): ...
config: Any
config = configure
def cget(self, key): ...
__getitem__: Any
def __setitem__(self, key, value): ...
def keys(self): ...
def pack_propagate(self, flag=...): ...
propagate: Any
def pack_slaves(self): ...
slaves: Any
def place_slaves(self): ...
def grid_anchor(self, anchor: Optional[Any] = ...): ...
anchor: Any
@overload
def pack_propagate(self, flag: bool) -> Optional[bool]: ...
@overload
def pack_propagate(self) -> None: ...
propagate = pack_propagate
def grid_anchor(self, anchor: Optional[_Anchor] = ...) -> None: ...
anchor = grid_anchor
@overload
def grid_bbox(
self, column: Optional[Any] = ..., row: Optional[Any] = ..., col2: Optional[Any] = ..., row2: Optional[Any] = ...
): ...
bbox: Any
def grid_columnconfigure(self, index, cnf=..., **kw): ...
columnconfigure: Any
def grid_location(self, x, y): ...
def grid_propagate(self, flag=...): ...
def grid_rowconfigure(self, index, cnf=..., **kw): ...
rowconfigure: Any
def grid_size(self): ...
size: Any
def grid_slaves(self, row: Optional[Any] = ..., column: Optional[Any] = ...): ...
self, column: None = ..., row: None = ..., col2: None = ..., row2: None = ...
) -> Optional[Tuple[int, int, int, int]]: ...
@overload
def grid_bbox(self, column: int, row: int, col2: None = ..., row2: None = ...) -> Optional[Tuple[int, int, int, int]]: ...
@overload
def grid_bbox(self, column: int, row: int, col2: int, row2: int) -> Optional[Tuple[int, int, int, int]]: ...
# commented out to avoid conflicting with other bbox methods
# bbox = grid_bbox
def grid_columnconfigure(self, index, cnf=..., **kw): ... # TODO
def grid_rowconfigure(self, index, cnf=..., **kw): ... # TODO
columnconfigure = grid_columnconfigure
rowconfigure = grid_rowconfigure
def grid_location(self, x: _ScreenUnits, y: _ScreenUnits) -> Tuple[int, int]: ...
@overload
def grid_propagate(self, flag: bool) -> None: ...
@overload
def grid_propagate(self) -> bool: ...
def grid_size(self) -> Tuple[int, int]: ...
size = grid_size
# Widget because Toplevel or Tk is never a slave
def pack_slaves(self) -> List[Widget]: ...
def grid_slaves(self, row: Optional[int] = ..., column: Optional[int] = ...) -> List[Widget]: ...
def place_slaves(self) -> List[Widget]: ...
slaves = pack_slaves
def event_add(self, virtual, *sequences): ...
def event_delete(self, virtual, *sequences): ...
def event_generate(self, sequence, **kw): ...
@ -379,47 +449,171 @@ class Tk(Misc, Wm):
def Tcl(screenName: Optional[Any] = ..., baseName: Optional[Any] = ..., className: str = ..., useTk: bool = ...): ...
_InMiscTotal = TypedDict("_InMiscTotal", {"in": Misc})
_InMiscNonTotal = TypedDict("_InMiscNonTotal", {"in": Misc}, total=False)
class _PackInfo(_InMiscTotal):
# 'before' and 'after' never appear in _PackInfo
anchor: _Anchor
expand: Literal[0, 1]
fill: Literal["none", "x", "y", "both"]
side: Literal["left", "right", "top", "bottom"]
# Paddings come out as int or tuple of int, even though any _ScreenUnits
# can be specified in pack().
ipadx: Union[int, Tuple[int, int]]
ipady: Union[int, Tuple[int, int]]
padx: Union[int, Tuple[int, int]]
pady: Union[int, Tuple[int, int]]
class Pack:
def pack_configure(self, cnf=..., **kw): ...
pack: Any
def pack_forget(self): ...
forget: Any
def pack_info(self): ...
info: Any
propagate: Any
slaves: Any
# _PackInfo is not the valid type for cnf because pad stuff accepts any
# _ScreenUnits instead of int only. I didn't bother to create another
# TypedDict for cnf because it appears to be a legacy thing that was
# replaced by **kwargs.
def pack_configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
*,
after: Misc = ...,
anchor: _Anchor = ...,
before: Misc = ...,
expand: bool = ...,
fill: Literal["none", "x", "y", "both"] = ...,
side: Literal["left", "right", "top", "bottom"] = ...,
ipadx: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ...,
ipady: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ...,
padx: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ...,
pady: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ...,
in_: Misc = ...,
) -> None: ...
def pack_forget(self) -> None: ...
def pack_info(self) -> _PackInfo: ... # errors if widget hasn't been packed
pack = pack_configure
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
# info = pack_info
# pack_propagate = Misc.pack_propagate
# configure = pack_configure
# config = pack_configure
# slaves = Misc.pack_slaves
# pack_slaves = Misc.pack_slaves
class _PlaceInfo(_InMiscNonTotal, total=False): # empty dict if widget hasn't been placed
anchor: _Anchor
bordermode: Literal["inside", "outside", "ignore"]
width: str # can be int()ed (even after e.g. widget.place(height='2.3c') or similar)
height: str # can be int()ed
x: str # can be int()ed
y: str # can be int()ed
relheight: str # can be float()ed if not empty string
relwidth: str # can be float()ed if not empty string
relx: float # can be float()ed if not empty string
rely: float # can be float()ed if not empty string
class Place:
def place_configure(self, cnf=..., **kw): ...
place: Any
def place_forget(self): ...
forget: Any
def place_info(self): ...
info: Any
slaves: Any
def place_configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
*,
anchor: _Anchor = ...,
bordermode: Literal["inside", "outside", "ignore"] = ...,
width: _ScreenUnits = ...,
height: _ScreenUnits = ...,
x: _ScreenUnits = ...,
y: _ScreenUnits = ...,
relheight: float = ...,
relwidth: float = ...,
relx: float = ...,
rely: float = ...,
in_: Misc = ...,
) -> None: ...
def place_forget(self) -> None: ...
def place_info(self) -> _PlaceInfo: ...
place = place_configure
info = place_info
# commented out to avoid mypy getting confused with multiple
# inheritance and how things get overrided with different things
# config = place_configure
# configure = place_configure
# forget = place_forget
# slaves = Misc.place_slaves
# place_slaves = Misc.place_slaves
class _GridInfo(_InMiscNonTotal, total=False): # empty dict if widget hasn't been gridded
column: int
columnspan: int
row: int
rowspan: int
ipadx: int
ipady: int
padx: int
pady: int
sticky: str # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty
class Grid:
def grid_configure(self, cnf=..., **kw): ...
grid: Any
bbox: Any
columnconfigure: Any
def grid_forget(self): ...
forget: Any
def grid_remove(self): ...
def grid_info(self): ...
info: Any
location: Any
propagate: Any
rowconfigure: Any
size: Any
slaves: Any
def grid_configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
*,
column: int = ...,
columnspan: int = ...,
row: int = ...,
rowspan: int = ...,
ipadx: _ScreenUnits = ...,
ipady: _ScreenUnits = ...,
padx: _ScreenUnits = ...,
pady: _ScreenUnits = ...,
sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty
in_: Misc = ...,
) -> None: ...
def grid_forget(self) -> None: ...
def grid_remove(self) -> None: ...
def grid_info(self) -> _GridInfo: ...
grid = grid_configure
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
# bbox = Misc.grid_bbox
# grid_bbox = Misc.grid_bbox
# forget = grid_forget
# info = grid_info
# grid_location = Misc.grid_location
# grid_propagate = Misc.grid_propagate
# grid_size = Misc.grid_size
# rowconfigure = Misc.grid_rowconfigure
# grid_rowconfigure = Misc.grid_rowconfigure
# grid_columnconfigure = Misc.grid_columnconfigure
# columnconfigure = Misc.grid_columnconfigure
# config = grid_configure
# configure = grid_configure
# propagate = Misc.grid_propagate
# slaves = Misc.grid_slaves
# grid_slaves = Misc.grid_slaves
class BaseWidget(Misc):
widgetName: Any
def __init__(self, master, widgetName, cnf=..., kw=..., extra=...): ...
def destroy(self): ...
class Widget(BaseWidget, Pack, Place, Grid): ...
# This class represents any widget except Toplevel or Tk.
class Widget(BaseWidget, Pack, Place, Grid):
# Allow bind callbacks to take e.g. Event[Label] instead of Event[Misc].
# Tk and Toplevel get notified for their child widgets' events, but other
# widgets don't.
@overload
def bind(
self: _W,
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[_W]], Optional[Literal["break"]]]] = ...,
add: Optional[bool] = ...,
) -> str: ...
@overload
def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
@overload
def bind(self, *, func: str, add: Optional[bool] = ...) -> None: ...
class Toplevel(BaseWidget, Wm):
def __init__(self, master: Optional[Any] = ..., cnf=..., **kw): ...
@ -440,8 +634,19 @@ class Canvas(Widget, XView, YView):
def addtag_overlapping(self, newtag, x1, y1, x2, y2): ...
def addtag_withtag(self, newtag, tagOrId): ...
def bbox(self, *args): ...
def tag_unbind(self, tagOrId, sequence, funcid: Optional[Any] = ...): ...
def tag_bind(self, tagOrId, sequence: Optional[Any] = ..., func: Optional[Any] = ..., add: Optional[Any] = ...): ...
@overload
def tag_bind(
self,
tagOrId: Union[str, int],
sequence: Optional[str] = ...,
func: Optional[Callable[[Event[Canvas]], Optional[Literal["break"]]]] = ...,
add: Optional[bool] = ...,
) -> str: ...
@overload
def tag_bind(self, tagOrId: Union[str, int], sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
@overload
def tag_bind(self, tagOrId: Union[str, int], *, func: str, add: Optional[bool] = ...) -> None: ...
def tag_unbind(self, tagOrId: Union[str, int], sequence: str, funcid: Optional[str] = ...) -> None: ...
def canvasx(self, screenx, gridspacing: Optional[Any] = ...): ...
def canvasy(self, screeny, gridspacing: Optional[Any] = ...): ...
def coords(self, *args): ...
@ -660,8 +865,18 @@ class Text(Widget, XView, YView):
): ...
def see(self, index): ...
def tag_add(self, tagName, index1, *args): ...
def tag_unbind(self, tagName, sequence, funcid: Optional[Any] = ...): ...
def tag_bind(self, tagName, sequence, func, add: Optional[Any] = ...): ...
# tag_bind stuff is very similar to Canvas
@overload
def tag_bind(
self,
tagName: str,
sequence: Optional[str],
func: Optional[Callable[[Event[Text]], Optional[Literal["break"]]]],
add: Optional[bool] = ...,
) -> str: ...
@overload
def tag_bind(self, tagName: str, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ...
def tag_unbind(self, tagName: str, sequence: str, funcid: Optional[str] = ...) -> None: ...
def tag_cget(self, tagName, option): ...
def tag_configure(self, tagName, cnf: Optional[Any] = ..., **kw): ...
tag_config: Any

View File

@ -1,79 +1,79 @@
from typing import Any
from typing_extensions import Literal
NO: Any
YES: Any
TRUE: Any
FALSE: Any
ON: Any
OFF: Any
N: Any
S: Any
W: Any
E: Any
NW: Any
SW: Any
NE: Any
SE: Any
NS: Any
EW: Any
NSEW: Any
CENTER: Any
NONE: Any
X: Any
Y: Any
BOTH: Any
LEFT: Any
TOP: Any
RIGHT: Any
BOTTOM: Any
RAISED: Any
SUNKEN: Any
FLAT: Any
RIDGE: Any
GROOVE: Any
SOLID: Any
HORIZONTAL: Any
VERTICAL: Any
NUMERIC: Any
CHAR: Any
WORD: Any
BASELINE: Any
INSIDE: Any
OUTSIDE: Any
SEL: Any
SEL_FIRST: Any
SEL_LAST: Any
END: Any
INSERT: Any
CURRENT: Any
ANCHOR: Any
ALL: Any
NORMAL: Any
DISABLED: Any
ACTIVE: Any
HIDDEN: Any
CASCADE: Any
CHECKBUTTON: Any
COMMAND: Any
RADIOBUTTON: Any
SEPARATOR: Any
SINGLE: Any
BROWSE: Any
MULTIPLE: Any
EXTENDED: Any
DOTBOX: Any
UNDERLINE: Any
PIESLICE: Any
CHORD: Any
ARC: Any
FIRST: Any
LAST: Any
BUTT: Any
PROJECTING: Any
ROUND: Any
BEVEL: Any
MITER: Any
MOVETO: Any
SCROLL: Any
UNITS: Any
PAGES: Any
NO: Literal[0]
YES: Literal[1]
TRUE: Literal[1]
FALSE: Literal[0]
ON: Literal[1]
OFF: Literal[0]
N: Literal["n"]
S: Literal["s"]
W: Literal["w"]
E: Literal["e"]
NW: Literal["nw"]
SW: Literal["sw"]
NE: Literal["ne"]
SE: Literal["se"]
NS: Literal["ns"]
EW: Literal["ew"]
NSEW: Literal["nsew"]
CENTER: Literal["center"]
NONE: Literal["none"]
X: Literal["x"]
Y: Literal["y"]
BOTH: Literal["both"]
LEFT: Literal["left"]
TOP: Literal["top"]
RIGHT: Literal["right"]
BOTTOM: Literal["bottom"]
RAISED: Literal["raised"]
SUNKEN: Literal["sunken"]
FLAT: Literal["flat"]
RIDGE: Literal["ridge"]
GROOVE: Literal["groove"]
SOLID: Literal["solid"]
HORIZONTAL: Literal["horizontal"]
VERTICAL: Literal["vertical"]
NUMERIC: Literal["numeric"]
CHAR: Literal["char"]
WORD: Literal["word"]
BASELINE: Literal["baseline"]
INSIDE: Literal["inside"]
OUTSIDE: Literal["outside"]
SEL: Literal["sel"]
SEL_FIRST: Literal["sel.first"]
SEL_LAST: Literal["sel.last"]
END: Literal["end"]
INSERT: Literal["insert"]
CURRENT: Literal["current"]
ANCHOR: Literal["anchor"]
ALL: Literal["all"]
NORMAL: Literal["normal"]
DISABLED: Literal["disabled"]
ACTIVE: Literal["active"]
HIDDEN: Literal["hidden"]
CASCADE: Literal["cascade"]
CHECKBUTTON: Literal["checkbutton"]
COMMAND: Literal["command"]
RADIOBUTTON: Literal["radiobutton"]
SEPARATOR: Literal["separator"]
SINGLE: Literal["single"]
BROWSE: Literal["browse"]
MULTIPLE: Literal["multiple"]
EXTENDED: Literal["extended"]
DOTBOX: Literal["dotbox"]
UNDERLINE: Literal["underline"]
PIESLICE: Literal["pieslice"]
CHORD: Literal["chord"]
ARC: Literal["arc"]
FIRST: Literal["first"]
LAST: Literal["last"]
BUTT: Literal["butt"]
PROJECTING: Literal["projecting"]
ROUND: Literal["round"]
BEVEL: Literal["bevel"]
MITER: Literal["miter"]
MOVETO: Literal["moveto"]
SCROLL: Literal["scroll"]
UNITS: Literal["units"]
PAGES: Literal["pages"]

View File

@ -1,6 +1,8 @@
import sys
import tkinter
from typing import Any, List, Optional
from tkinter import Event
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload
from typing_extensions import Literal
def tclobjs_to_py(adict): ...
def setup_master(master: Optional[Any] = ...): ...
@ -145,7 +147,19 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
def selection_remove(self, items): ...
def selection_toggle(self, items): ...
def set(self, item, column: Optional[Any] = ..., value: Optional[Any] = ...): ...
def tag_bind(self, tagname, sequence: Optional[Any] = ..., callback: Optional[Any] = ...): ...
# There's no tag_unbind() or 'add' argument for whatever reason.
# Also, it's 'callback' instead of 'func' here.
@overload
def tag_bind(
self,
tagname: str,
sequence: Optional[str] = ...,
callback: Optional[Callable[[Event[Treeview]], Optional[Literal["break"]]]] = ...,
) -> str: ...
@overload
def tag_bind(self, tagname: str, sequence: Optional[str], callback: str) -> None: ...
@overload
def tag_bind(self, tagname: str, *, callback: str) -> None: ...
def tag_configure(self, tagname, option: Optional[Any] = ..., **kw): ...
def tag_has(self, tagname, item: Optional[Any] = ...): ...

View File

@ -170,7 +170,6 @@ class Iterator(Iterable[_T_co], Protocol[_T_co]):
def __iter__(self) -> Iterator[_T_co]: ...
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@abstractmethod
def __next__(self) -> _T_co: ...
@abstractmethod
def send(self, __value: _T_contra) -> _T_co: ...
@ -182,9 +181,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ...
@abstractmethod
def close(self) -> None: ...
@abstractmethod
def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...
@property
def gi_code(self) -> CodeType: ...

View File

@ -51,13 +51,13 @@ class _Call(Tuple[Any, ...]):
) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...
call: Any
call: _Call
class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...

View File

@ -51,13 +51,13 @@ class _Call(Tuple[Any, ...]):
) -> None: ...
def __eq__(self, other: Any) -> bool: ...
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
def __getattr__(self, attr: Any) -> Any: ...
def count(self, *args: Any, **kwargs: Any) -> Any: ...
def index(self, *args: Any, **kwargs: Any) -> Any: ...
def call_list(self) -> Any: ...
call: Any
call: _Call
class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...

View File

@ -17,6 +17,7 @@ from typing import (
NoReturn as NoReturn,
Optional,
Text as Text,
Tuple,
Type as Type,
TypeVar,
ValuesView,
@ -88,6 +89,9 @@ def get_type_hints(
include_extras: bool = ...,
) -> Dict[str, Any]: ...
if sys.version_info >= (3, 7):
def get_args(tp: Any) -> Tuple[Any, ...]: ...
Annotated: _SpecialForm = ...
_AnnotatedAlias: Any = ... # undocumented

View File

@ -14,17 +14,16 @@ def _get_mock_module(config: _Config) -> _MockModule: ...
class MockFixture:
mock_module: _MockModule
patch: MockFixture._Patcher # google/pytype#611
# The following aliases don't work due to google/pytype#612
Mock: Any # actually unittest.mock.Mock
MagicMock: Any # actually unittest.mock.MagicMock
NonCallableMock: Any # actually unittest.mock.NonCallableMock
PropertyMock: Any # actually unittest.mock.PropertyMock
call: Any # actually unittest.mock.call
ANY: Any # actually unittest.mock.ANY
DEFAULT: Any # actually unittest.mock.DEFAULT
create_autospec: Any # actually unittest.mock.create_autospec
sentinel: Any # actually unittest.mock.sentinel
mock_open: Any # actually unittest.mock.mock_open
Mock = unittest.mock.Mock
MagicMock = unittest.mock.MagicMock
NonCallableMock = unittest.mock.NonCallableMock
PropertyMock = unittest.mock.PropertyMock
call = unittest.mock.call
ANY = unittest.mock.ANY
DEFAULT = unittest.mock.DEFAULT
create_autospec = unittest.mock.create_autospec
sentinel = unittest.mock.sentinel
mock_open = unittest.mock.mock_open
def __init__(self, config: _Config) -> None: ...
def resetall(self) -> None: ...
def stopall(self) -> None: ...