[ty] Sync vendored typeshed stubs (#20658)

---------

Co-authored-by: typeshedbot <>
Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
github-actions[bot] 2025-10-01 10:11:48 +02:00 committed by GitHub
parent a422716267
commit d9473a2fcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1024 additions and 979 deletions

View file

@ -561,13 +561,13 @@ f(**kwargs<CURSOR>)
assert_snapshot!(test.goto_type_definition(), @r#"
info[goto-type-definition]: Type definition
--> stdlib/types.pyi:941:11
--> stdlib/types.pyi:950:11
|
939 | if sys.version_info >= (3, 10):
940 | @final
941 | class NoneType:
948 | if sys.version_info >= (3, 10):
949 | @final
950 | class NoneType:
| ^^^^^^^^
942 | """The type of the None singleton."""
951 | """The type of the None singleton."""
|
info: Source
--> main.py:3:5

View file

@ -17,7 +17,8 @@ from datetime import time
t = time(12, 0, 0)
t = replace(t, minute=30)
reveal_type(t) # revealed: time
# TODO: this should be `time`, once we support specialization of generic protocols
reveal_type(t) # revealed: Unknown
```
## The `__replace__` protocol
@ -47,7 +48,8 @@ b = a.__replace__(x=3, y=4)
reveal_type(b) # revealed: Point
b = replace(a, x=3, y=4)
reveal_type(b) # revealed: Point
# TODO: this should be `Point`, once we support specialization of generic protocols
reveal_type(b) # revealed: Unknown
```
A call to `replace` does not require all keyword arguments:
@ -57,7 +59,8 @@ c = a.__replace__(y=4)
reveal_type(c) # revealed: Point
d = replace(a, y=4)
reveal_type(d) # revealed: Point
# TODO: this should be `Point`, once we support specialization of generic protocols
reveal_type(d) # revealed: Unknown
```
Invalid calls to `__replace__` or `replace` will raise an error:

View file

@ -4403,8 +4403,8 @@ impl KnownClass {
KnownClassDisplay { db, class: self }
}
/// Lookup a [`KnownClass`] in typeshed and return a [`Type`]
/// representing all possible instances of the class.
/// Lookup a [`KnownClass`] in typeshed and return a [`Type`] representing all possible instances of
/// the class. If this class is generic, this will use the default specialization.
///
/// If the class cannot be found in typeshed, a debug-level log message will be emitted stating this.
pub(crate) fn to_instance(self, db: &dyn Db) -> Type<'_> {
@ -4414,6 +4414,14 @@ impl KnownClass {
.unwrap_or_else(Type::unknown)
}
/// Similar to [`KnownClass::to_instance`], but returns the Unknown-specialization where each type
/// parameter is specialized to `Unknown`.
pub(crate) fn to_instance_unknown(self, db: &dyn Db) -> Type<'_> {
self.try_to_class_literal(db)
.map(|literal| Type::instance(db, literal.unknown_specialization(db)))
.unwrap_or_else(Type::unknown)
}
/// Lookup a generic [`KnownClass`] in typeshed and return a [`Type`]
/// representing a specialization of that class.
///

View file

@ -1923,8 +1923,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
//
// If type arguments are supplied to `(Async)Iterable`, `(Async)Iterator`,
// `(Async)Generator` or `(Async)GeneratorType` in the return annotation,
// we should iterate over the `yield` expressions and `return` statements in the function
// to check that they are consistent with the type arguments provided.
// we should iterate over the `yield` expressions and `return` statements
// in the function to check that they are consistent with the type arguments
// provided. Once we do this, the `.to_instance_unknown` call below should
// be replaced with `.to_specialized_instance`.
let inferred_return = if function.is_async {
KnownClass::AsyncGeneratorType
} else {
@ -1932,7 +1934,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
};
if !inferred_return
.to_instance(self.db())
.to_instance_unknown(self.db())
.is_assignable_to(self.db(), expected_ty)
{
report_invalid_generator_function_return_type(

View file

@ -1 +1 @@
47dbbd6c914a5190d54bc5bd498d1e6633d97db2
91055c730ffcda6311654cf32d663858ece69bad

View file

@ -6,12 +6,13 @@ Unit tests are in test_collections.
import sys
from abc import abstractmethod
from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035
from typing import ( # noqa: Y022,Y038,UP035,Y057
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
ClassVar,
Collection as Collection,
@ -64,12 +65,8 @@ __all__ = [
"ValuesView",
"Sequence",
"MutableSequence",
"ByteString",
]
if sys.version_info < (3, 14):
from typing import ByteString as ByteString # noqa: Y057,UP035
__all__ += ["ByteString"]
if sys.version_info >= (3, 12):
__all__ += ["Buffer"]

View file

@ -22,7 +22,7 @@ def __import__(
name: str,
globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] = (),
fromlist: Sequence[str] | None = (),
level: int = 0,
) -> ModuleType:
"""Import a module.

View file

@ -57,34 +57,34 @@ _TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
@final
class TkappType:
# Please keep in sync with tkinter.Tk
def adderrorinfo(self, msg, /): ...
def adderrorinfo(self, msg: str, /): ...
def call(self, command: Any, /, *args: Any) -> Any: ...
def createcommand(self, name, func, /): ...
def createcommand(self, name: str, func, /): ...
if sys.platform != "win32":
def createfilehandler(self, file, mask, func, /): ...
def deletefilehandler(self, file, /): ...
def createfilehandler(self, file, mask: int, func, /): ...
def deletefilehandler(self, file, /) -> None: ...
def createtimerhandler(self, milliseconds, func, /): ...
def deletecommand(self, name, /): ...
def createtimerhandler(self, milliseconds: int, func, /): ...
def deletecommand(self, name: str, /): ...
def dooneevent(self, flags: int = 0, /): ...
def eval(self, script: str, /) -> str: ...
def evalfile(self, fileName, /): ...
def exprboolean(self, s, /): ...
def exprdouble(self, s, /): ...
def exprlong(self, s, /): ...
def exprstring(self, s, /): ...
def getboolean(self, arg, /): ...
def getdouble(self, arg, /): ...
def getint(self, arg, /): ...
def evalfile(self, fileName: str, /): ...
def exprboolean(self, s: str, /): ...
def exprdouble(self, s: str, /): ...
def exprlong(self, s: str, /): ...
def exprstring(self, s: str, /): ...
def getboolean(self, arg, /) -> bool: ...
def getdouble(self, arg, /) -> float: ...
def getint(self, arg, /) -> int: ...
def getvar(self, *args, **kwargs): ...
def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self) -> int: ...
def loadtk(self) -> None: ...
def mainloop(self, threshold: int = 0, /): ...
def quit(self): ...
def record(self, script, /): ...
def mainloop(self, threshold: int = 0, /) -> None: ...
def quit(self) -> None: ...
def record(self, script: str, /): ...
def setvar(self, *ags, **kwargs): ...
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
@ -93,7 +93,7 @@ class TkappType:
def splitlist(self, arg, /): ...
def unsetvar(self, *args, **kwargs): ...
def wantobjects(self, *args, **kwargs): ...
def willdispatch(self): ...
def willdispatch(self) -> None: ...
if sys.version_info >= (3, 12):
def gettrace(self, /) -> _TkinterTraceFunc | None:
"""Get the tracing function."""
@ -164,10 +164,10 @@ else:
if not None, then pass -use to wish
"""
def getbusywaitinterval():
def getbusywaitinterval() -> int:
"""Return the current busy-wait interval between successive calls to Tcl_DoOneEvent in a threaded Python interpreter."""
def setbusywaitinterval(new_val, /):
def setbusywaitinterval(new_val: int, /) -> None:
"""Set the busy-wait interval in milliseconds between successive calls to Tcl_DoOneEvent in a threaded Python interpreter.
It should be set to a divisor of the maximum time between frames in an animation.

View file

@ -1,5 +1,6 @@
"""Tools to analyze tasks running in asyncio programs."""
import sys
from collections.abc import Iterable
from enum import Enum
from typing import NamedTuple, SupportsIndex, type_check_only
@ -48,6 +49,15 @@ def build_async_tree(result: Iterable[_AwaitedInfo], task_emoji: str = "(T)", co
"""
def build_task_table(result: Iterable[_AwaitedInfo]) -> list[list[int | str]]: ...
if sys.version_info >= (3, 14):
def exit_with_permission_help_text() -> None:
"""
Prints a message pointing to platform-specific permission help text and exits the program.
This function is called when a PermissionError is encountered while trying
to attach to a process.
"""
def display_awaited_by_tasks_table(pid: SupportsIndex) -> None:
"""Build and print a table of all pending tasks under `pid`."""

View file

@ -4153,7 +4153,14 @@ def open(
opener: _Opener | None = None,
) -> IO[Any]: ...
def ord(c: str | bytes | bytearray, /) -> int:
"""Return the Unicode code point for a one-character string."""
"""Return the ordinal value of a character.
If the argument is a one-character string, return the Unicode code
point of that character.
If the argument is a bytes or bytearray object of length 1, return its
single byte value.
"""
@type_check_only
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T_contra]): ...
@ -4451,7 +4458,7 @@ def __import__(
name: str,
globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] = (),
fromlist: Sequence[str] | None = (),
level: int = 0,
) -> types.ModuleType:
"""Import a module.

View file

@ -71,60 +71,74 @@ if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <
def empty(self) -> bool: ...
def full(self) -> bool: ...
def qsize(self) -> int: ...
def put(
self,
obj: object,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None:
"""Add the object to the queue.
if sys.version_info >= (3, 14):
def put(
self,
obj: object,
block: bool = True,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None:
"""Add the object to the queue.
This blocks while the queue is full.
If "block" is true, this blocks while the queue is full.
For most objects, the object received through Queue.get() will
be a new one, equivalent to the original and not sharing any
actual underlying data. The notable exceptions include
cross-interpreter types (like Queue) and memoryview, where the
underlying data is actually shared. Furthermore, some types
can be sent through a queue more efficiently than others. This
group includes various immutable types like int, str, bytes, and
tuple (if the items are likewise efficiently shareable). See interpreters.is_shareable().
For most objects, the object received through Queue.get() will
be a new one, equivalent to the original and not sharing any
actual underlying data. The notable exceptions include
cross-interpreter types (like Queue) and memoryview, where the
underlying data is actually shared. Furthermore, some types
can be sent through a queue more efficiently than others. This
group includes various immutable types like int, str, bytes, and
tuple (if the items are likewise efficiently shareable). See interpreters.is_shareable().
"unbounditems" controls the behavior of Queue.get() for the given
object if the current interpreter (calling put()) is later
destroyed.
"unbounditems" controls the behavior of Queue.get() for the given
object if the current interpreter (calling put()) is later
destroyed.
If "unbounditems" is None (the default) then it uses the
queue's default, set with create_queue(),
which is usually UNBOUND.
If "unbounditems" is None (the default) then it uses the
queue's default, set with create_queue(),
which is usually UNBOUND.
If "unbounditems" is UNBOUND_ERROR then get() will raise an
ItemInterpreterDestroyed exception if the original interpreter
has been destroyed. This does not otherwise affect the queue;
the next call to put() will work like normal, returning the next
item in the queue.
If "unbounditems" is UNBOUND_ERROR then get() will raise an
ItemInterpreterDestroyed exception if the original interpreter
has been destroyed. This does not otherwise affect the queue;
the next call to put() will work like normal, returning the next
item in the queue.
If "unbounditems" is UNBOUND_REMOVE then the item will be removed
from the queue as soon as the original interpreter is destroyed.
Be aware that this will introduce an imbalance between put()
and get() calls.
If "unbounditems" is UNBOUND_REMOVE then the item will be removed
from the queue as soon as the original interpreter is destroyed.
Be aware that this will introduce an imbalance between put()
and get() calls.
If "unbounditems" is UNBOUND then it is returned by get() in place
of the unbound item.
"""
If "unbounditems" is UNBOUND then it is returned by get() in place
of the unbound item.
"""
else:
def put(
self,
obj: object,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None: ...
def put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ...
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object:
"""Return the next object from the queue.
if sys.version_info >= (3, 14):
def get(self, block: bool = True, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object:
"""Return the next object from the queue.
This blocks while the queue is empty.
If "block" is true, this blocks while the queue is empty.
If the next item's original interpreter has been destroyed
then the "next object" is determined by the value of the
"unbounditems" argument to put().
"""
If the next item's original interpreter has been destroyed
then the "next object" is determined by the value of the
"unbounditems" argument to put().
"""
else:
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
def get_nowait(self) -> object:
"""Return the next object from the channel.

View file

@ -429,9 +429,9 @@ class RawConfigParser(_Parser):
) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key: str) -> SectionProxy: ...
def __setitem__(self, key: str, value: _Section) -> None: ...
def __delitem__(self, key: str) -> None: ...
def __getitem__(self, key: _SectionName) -> SectionProxy: ...
def __setitem__(self, key: _SectionName, value: _Section) -> None: ...
def __delitem__(self, key: _SectionName) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __contains__(self, key: object) -> bool: ...
def defaults(self) -> _Section: ...

View file

@ -51,17 +51,16 @@ __getstate__() and __setstate__(). See the documentation for module
import sys
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import Self
__all__ = ["Error", "copy", "deepcopy"]
_T = TypeVar("_T")
_SR = TypeVar("_SR", bound=_SupportsReplace)
_RT_co = TypeVar("_RT_co", covariant=True)
@type_check_only
class _SupportsReplace(Protocol):
# In reality doesn't support args, but there's no other great way to express this.
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
class _SupportsReplace(Protocol[_RT_co]):
# In reality doesn't support args, but there's no great way to express this.
def __replace__(self, /, *_: Any, **changes: Any) -> _RT_co: ...
# None in CPython but non-None in Jython
PyStringMap: Any
@ -81,7 +80,8 @@ def copy(x: _T) -> _T:
if sys.version_info >= (3, 13):
__all__ += ["replace"]
def replace(obj: _SR, /, **changes: Any) -> _SR:
# The types accepted by `**changes` match those of `obj.__replace__`.
def replace(obj: _SupportsReplace[_RT_co], /, **changes: Any) -> _RT_co:
"""Return a new object replacing specified fields with new values.
This is especially useful for immutable objects, like named tuples or

View file

@ -26,8 +26,9 @@ _T = TypeVar("_T")
_P = ParamSpec("_P")
# available after calling `curses.initscr()`
LINES: Final[int]
COLS: Final[int]
# not `Final` as it can change during the terminal resize:
LINES: int
COLS: int
# available after calling `curses.start_color()`
COLORS: Final[int]

View file

@ -26,7 +26,7 @@ class _Database(MutableMapping[bytes, bytes]):
def __enter__(self) -> Self: ...
def __exit__(self, *args: Unused) -> None: ...
def open(filename: StrOrBytesPath, /, flag: Literal["r", "w,", "c", "n"] = "r", mode: int = 0o666) -> _Database:
def open(filename: StrOrBytesPath, /, flag: Literal["r", "w", "c", "n"] = "r", mode: int = 0o666) -> _Database:
"""Open a dbm.sqlite3 database and return the dbm object.
The 'filename' parameter is the name of the database file.

View file

@ -122,7 +122,7 @@ class DateHeader:
max_count: ClassVar[Literal[1] | None]
def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect], datetime: _datetime) -> None: ...
@property
def datetime(self) -> _datetime: ...
def datetime(self) -> _datetime | None: ...
@staticmethod
def value_parser(value: str) -> UnstructuredTokenList:
"""unstructured = (*([FWS] vchar) *WSP) / obs-unstruct

View file

@ -135,6 +135,7 @@ if sys.platform == "darwin":
ESHLIBVERS: Final[int]
if sys.version_info >= (3, 11):
EQFULL: Final[int]
ENOTCAPABLE: Final[int] # available starting with 3.11.1
if sys.platform != "darwin":
EDEADLOCK: Final[int]

View file

@ -21,8 +21,13 @@ def dump_traceback_later(timeout: float, repeat: bool = ..., file: FileDescripto
or each timeout seconds if repeat is True. If exit is True, call _exit(1) which is not safe.
"""
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None:
"""Enable the fault handler."""
if sys.version_info >= (3, 14):
def enable(file: FileDescriptorLike = ..., all_threads: bool = ..., c_stack: bool = True) -> None:
"""Enable the fault handler."""
else:
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None:
"""Enable the fault handler."""
def is_enabled() -> bool:
"""Check if the handler is enabled."""

View file

@ -9,7 +9,7 @@ get_stats() -- Return list of dictionaries containing per-generation stats.
set_debug() -- Set debugging flags.
get_debug() -- Get debugging flags.
set_threshold() -- Set the collection thresholds.
get_threshold() -- Return the current the collection thresholds.
get_threshold() -- Return the current collection thresholds.
get_objects() -- Return a list of all objects tracked by the collector.
is_tracked() -- Returns true if a given object is tracked.
is_finalized() -- Returns true if a given object has been already finalized.

View file

@ -24,8 +24,8 @@ if sys.version_info >= (3, 14):
prompt: Written on stream to ask for the input. Default: 'Password: '
stream: A writable file object to display the prompt. Defaults to
the tty. If no tty is available defaults to sys.stderr.
echo_char: A string used to mask input (e.g., '*'). If None, input is
hidden.
echo_char: A single ASCII character to mask input (e.g., '*').
If None, input is hidden.
Returns:
The seKr3t input.
Raises:

View file

@ -37,7 +37,7 @@ if sys.version_info >= (3, 11):
"""
@overload
@deprecated("First parameter to files is renamed to 'anchor'")
@deprecated("Deprecated since Python 3.12; will be removed in Python 3.15. Use `anchor` parameter instead.")
def files(package: Anchor | None = None) -> Traversable: ...
else:

View file

@ -37,7 +37,7 @@ class SharedMemory:
def __init__(self, name: str | None = None, create: bool = False, size: int = 0) -> None: ...
@property
def buf(self) -> memoryview:
def buf(self) -> memoryview | None:
"""A memoryview of contents of the shared memory block."""
@property

File diff suppressed because it is too large Load diff

View file

@ -64,21 +64,19 @@ def setup_master(master: tkinter.Misc | None = None):
"""
_Padding: TypeAlias = (
tkinter._ScreenUnits
| tuple[tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits]
float
| str
| tuple[float | str]
| tuple[float | str, float | str]
| tuple[float | str, float | str, float | str]
| tuple[float | str, float | str, float | str, float | str]
)
# from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound
_TtkCompound: TypeAlias = Literal["", "text", "image", tkinter._Compound]
# Last item (option value to apply) varies between different options so use Any.
# It could also be any iterable with items matching the tuple, but that case
# hasn't been added here for consistency with _Padding above.
_Statespec: TypeAlias = tuple[Unpack[tuple[str, ...]], Any]
_ImageStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], tkinter._ImageSpec]
_ImageStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], tkinter._Image | str]
_VsapiStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], int]
class _Layout(TypedDict, total=False):
@ -94,14 +92,14 @@ _LayoutSpec: TypeAlias = list[tuple[str, _Layout | None]]
# Keep these in sync with the appropriate methods in Style
class _ElementCreateImageKwargs(TypedDict, total=False):
border: _Padding
height: tkinter._ScreenUnits
height: float | str
padding: _Padding
sticky: str
width: tkinter._ScreenUnits
width: float | str
_ElementCreateArgsCrossPlatform: TypeAlias = (
# Could be any sequence here but types are not homogenous so just type it as tuple
tuple[Literal["image"], tkinter._ImageSpec, Unpack[tuple[_ImageStatespec, ...]], _ElementCreateImageKwargs]
tuple[Literal["image"], tkinter._Image | str, Unpack[tuple[_ImageStatespec, ...]], _ElementCreateImageKwargs]
| tuple[Literal["from"], str, str]
| tuple[Literal["from"], str] # (fromelement is optional)
)
@ -113,8 +111,8 @@ if sys.platform == "win32" and sys.version_info >= (3, 13):
padding: _Padding
class _ElementCreateVsapiKwargsSize(TypedDict):
width: tkinter._ScreenUnits
height: tkinter._ScreenUnits
width: float | str
height: float | str
_ElementCreateVsapiKwargsDict: TypeAlias = (
_ElementCreateVsapiKwargsPadding | _ElementCreateVsapiKwargsMargin | _ElementCreateVsapiKwargsSize
@ -222,14 +220,14 @@ class Style:
self,
elementname: str,
etype: Literal["image"],
default_image: tkinter._ImageSpec,
default_image: tkinter._Image | str,
/,
*imagespec: _ImageStatespec,
border: _Padding = ...,
height: tkinter._ScreenUnits = ...,
height: float | str = ...,
padding: _Padding = ...,
sticky: str = ...,
width: tkinter._ScreenUnits = ...,
width: float | str = ...,
) -> None:
"""Create a new element in the current theme of given etype."""
@ -275,8 +273,8 @@ class Style:
vs_statespec: _VsapiStatespec = ...,
/,
*,
width: tkinter._ScreenUnits,
height: tkinter._ScreenUnits,
width: float | str,
height: float | str,
) -> None: ...
def element_names(self) -> tuple[str, ...]:
@ -376,16 +374,16 @@ class Button(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
compound: _TtkCompound = "",
command: str | Callable[[], Any] = "",
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "",
cursor: tkinter._Cursor = "",
default: Literal["normal", "active", "disabled"] = "normal",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@ -408,15 +406,15 @@ class Button(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
command: str | Callable[[], Any] = ...,
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ...,
cursor: tkinter._Cursor = ...,
default: Literal["normal", "active", "disabled"] = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@ -443,17 +441,17 @@ class Checkbutton(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
compound: _TtkCompound = "",
command: str | Callable[[], Any] = "",
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "",
cursor: tkinter._Cursor = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
offvalue: Any = 0,
onvalue: Any = 1,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@ -480,16 +478,16 @@ class Checkbutton(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
command: str | Callable[[], Any] = ...,
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ...,
cursor: tkinter._Cursor = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
offvalue: Any = ...,
onvalue: Any = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@ -532,18 +530,18 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = True,
font: _FontDescription = "TkTextFont",
foreground: str = "",
invalidcommand: tkinter._EntryValidateCommand = "",
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
justify: Literal["left", "center", "right"] = "left",
name: str = ...,
show: str = "",
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none",
validatecommand: tkinter._EntryValidateCommand = "",
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
width: int = 20,
xscrollcommand: tkinter._XYScrollCommand = "",
xscrollcommand: str | Callable[[float, float], object] = "",
) -> None:
"""Constructs a Ttk Entry widget with the parent master.
@ -571,17 +569,17 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = ...,
font: _FontDescription = ...,
foreground: str = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show: str = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -603,17 +601,17 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = ...,
font: _FontDescription = ...,
foreground: str = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show: str = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -656,20 +654,20 @@ class Combobox(Entry):
font: _FontDescription = ..., # undocumented
foreground: str = ..., # undocumented
height: int = 10,
invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
justify: Literal["left", "center", "right"] = "left",
name: str = ...,
postcommand: Callable[[], object] | str = "",
show=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented
validatecommand: tkinter._EntryValidateCommand = ..., # undocumented
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
values: list[str] | tuple[str, ...] = ...,
width: int = 20,
xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented
xscrollcommand: str | Callable[[float, float], object] = ..., # undocumented
) -> None:
"""Construct a Ttk Combobox widget with the parent master.
@ -694,19 +692,19 @@ class Combobox(Entry):
font: _FontDescription = ...,
foreground: str = ...,
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Callable[[], object] | str = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -729,19 +727,19 @@ class Combobox(Entry):
font: _FontDescription = ...,
foreground: str = ...,
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Callable[[], object] | str = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -773,17 +771,17 @@ class Frame(Widget):
self,
master: tkinter.Misc | None = None,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
border: float | str = ...,
borderwidth: float | str = ...,
class_: str = "",
cursor: tkinter._Cursor = "",
height: tkinter._ScreenUnits = 0,
height: float | str = 0,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
width: tkinter._ScreenUnits = 0,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: float | str = 0,
) -> None:
"""Construct a Ttk Frame with parent master.
@ -801,15 +799,15 @@ class Frame(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
border: float | str = ...,
borderwidth: float | str = ...,
cursor: tkinter._Cursor = ...,
height: tkinter._ScreenUnits = ...,
height: float | str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
width: tkinter._ScreenUnits = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: float | str = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -829,28 +827,28 @@ class Label(Widget):
self,
master: tkinter.Misc | None = None,
*,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
background: str = "",
border: tkinter._ScreenUnits = ..., # alias for borderwidth
borderwidth: tkinter._ScreenUnits = ..., # undocumented
border: float | str = ..., # alias for borderwidth
borderwidth: float | str = ..., # undocumented
class_: str = "",
compound: _TtkCompound = "",
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "",
cursor: tkinter._Cursor = "",
font: _FontDescription = ...,
foreground: str = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
justify: Literal["left", "center", "right"] = ...,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
width: int | Literal[""] = "",
wraplength: tkinter._ScreenUnits = ...,
wraplength: float | str = ...,
) -> None:
"""Construct a Ttk Label with parent master.
@ -870,26 +868,26 @@ class Label(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
background: str = ...,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
compound: _TtkCompound = ...,
border: float | str = ...,
borderwidth: float | str = ...,
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ...,
cursor: tkinter._Cursor = ...,
font: _FontDescription = ...,
foreground: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
justify: Literal["left", "center", "right"] = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: int | Literal[""] = ...,
wraplength: tkinter._ScreenUnits = ...,
wraplength: float | str = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -912,21 +910,21 @@ class Labelframe(Widget):
self,
master: tkinter.Misc | None = None,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ..., # undocumented
border: float | str = ...,
borderwidth: float | str = ..., # undocumented
class_: str = "",
cursor: tkinter._Cursor = "",
height: tkinter._ScreenUnits = 0,
height: float | str = 0,
labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ...,
labelwidget: tkinter.Misc = ...,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ..., # undocumented
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., # undocumented
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
text: float | str = "",
underline: int = -1,
width: tkinter._ScreenUnits = 0,
width: float | str = 0,
) -> None:
"""Construct a Ttk Labelframe with parent master.
@ -944,19 +942,19 @@ class Labelframe(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
border: float | str = ...,
borderwidth: float | str = ...,
cursor: tkinter._Cursor = ...,
height: tkinter._ScreenUnits = ...,
height: float | str = ...,
labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ...,
labelwidget: tkinter.Misc = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
underline: int = ...,
width: tkinter._ScreenUnits = ...,
width: float | str = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -981,16 +979,16 @@ class Menubutton(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
compound: _TtkCompound = "",
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "",
cursor: tkinter._Cursor = "",
direction: Literal["above", "below", "left", "right", "flush"] = "below",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
menu: tkinter.Menu = ...,
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@ -1013,15 +1011,15 @@ class Menubutton(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
compound: _TtkCompound = ...,
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ...,
cursor: tkinter._Cursor = ...,
direction: Literal["above", "below", "left", "right", "flush"] = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
menu: tkinter.Menu = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@ -1054,7 +1052,7 @@ class Notebook(Widget):
name: str = ...,
padding: _Padding = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = 0,
) -> None:
"""Construct a Ttk Notebook with parent master.
@ -1095,7 +1093,7 @@ class Notebook(Widget):
height: int = ...,
padding: _Padding = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1119,7 +1117,7 @@ class Notebook(Widget):
# `image` is a sequence of an image name, followed by zero or more
# (sequences of one or more state names followed by an image name)
image=...,
compound: tkinter._Compound = ...,
compound: Literal["top", "left", "center", "right", "bottom", "none"] = ...,
underline: int = ...,
) -> None:
"""Adds a new tab to the notebook.
@ -1217,7 +1215,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
name: str = ...,
orient: Literal["vertical", "horizontal"] = "vertical", # can't be changed with configure()
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: int = 0,
) -> None:
"""Construct a Ttk Panedwindow with parent master.
@ -1252,7 +1250,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1273,7 +1271,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1329,14 +1327,14 @@ class Progressbar(Widget):
*,
class_: str = "",
cursor: tkinter._Cursor = "",
length: tkinter._ScreenUnits = 100,
length: float | str = 100,
maximum: float = 100,
mode: Literal["determinate", "indeterminate"] = "determinate",
name: str = ...,
orient: Literal["horizontal", "vertical"] = "horizontal",
phase: int = 0, # docs say read-only but assigning int to this works
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
value: float = 0.0,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> None:
@ -1357,13 +1355,13 @@ class Progressbar(Widget):
cnf: dict[str, Any] | None = None,
*,
cursor: tkinter._Cursor = ...,
length: tkinter._ScreenUnits = ...,
length: float | str = ...,
maximum: float = ...,
mode: Literal["determinate", "indeterminate"] = ...,
orient: Literal["horizontal", "vertical"] = ...,
phase: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
@ -1405,15 +1403,15 @@ class Radiobutton(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
compound: _TtkCompound = "",
command: str | Callable[[], Any] = "",
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "",
cursor: tkinter._Cursor = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@ -1438,14 +1436,14 @@ class Radiobutton(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
command: str | Callable[[], Any] = ...,
compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ...,
cursor: tkinter._Cursor = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@ -1485,12 +1483,12 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
command: str | Callable[[str], object] = "",
cursor: tkinter._Cursor = "",
from_: float = 0,
length: tkinter._ScreenUnits = 100,
length: float | str = 100,
name: str = ...,
orient: Literal["horizontal", "vertical"] = "horizontal",
state: str = ..., # undocumented
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = 1.0,
value: float = 0,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@ -1514,11 +1512,11 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
command: str | Callable[[str], object] = ...,
cursor: tkinter._Cursor = ...,
from_: float = ...,
length: tkinter._ScreenUnits = ...,
length: float | str = ...,
orient: Literal["horizontal", "vertical"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@ -1540,11 +1538,11 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
command: str | Callable[[str], object] = ...,
cursor: tkinter._Cursor = ...,
from_: float = ...,
length: tkinter._ScreenUnits = ...,
length: float | str = ...,
orient: Literal["horizontal", "vertical"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@ -1580,7 +1578,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
name: str = ...,
orient: Literal["horizontal", "vertical"] = "vertical",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None:
"""Construct a Ttk Scrollbar with parent master.
@ -1602,7 +1600,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1623,7 +1621,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1649,7 +1647,7 @@ class Separator(Widget):
name: str = ...,
orient: Literal["horizontal", "vertical"] = "horizontal",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None:
"""Construct a Ttk Separator with parent master.
@ -1670,7 +1668,7 @@ class Separator(Widget):
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1696,7 +1694,7 @@ class Sizegrip(Widget):
cursor: tkinter._Cursor = ...,
name: str = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None:
"""Construct a Ttk Sizegrip with parent master.
@ -1712,7 +1710,7 @@ class Sizegrip(Widget):
*,
cursor: tkinter._Cursor = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1746,21 +1744,21 @@ class Spinbox(Entry):
format: str = "",
from_: float = 0,
increment: float = 1,
invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
justify: Literal["left", "center", "right"] = ..., # undocumented
name: str = ...,
show=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ..., # undocumented
to: float = 0,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none",
validatecommand: tkinter._EntryValidateCommand = "",
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
values: list[str] | tuple[str, ...] = ...,
width: int = ..., # undocumented
wrap: bool = False,
xscrollcommand: tkinter._XYScrollCommand = "",
xscrollcommand: str | Callable[[float, float], object] = "",
) -> None:
"""Construct a Ttk Spinbox widget with the parent master.
@ -1788,20 +1786,20 @@ class Spinbox(Entry):
format: str = ...,
from_: float = ...,
increment: float = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
to: float = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
wrap: bool = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1836,7 +1834,7 @@ class _TreeviewTagDict(TypedDict):
class _TreeviewHeaderDict(TypedDict):
text: str
image: list[str] | Literal[""]
anchor: tkinter._Anchor
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"]
command: str
state: str # Doesn't seem to appear anywhere else than in these dicts
@ -1845,7 +1843,7 @@ class _TreeviewColumnDict(TypedDict):
width: int
minwidth: int
stretch: bool # actually 0 or 1
anchor: tkinter._Anchor
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"]
id: str
class Treeview(Widget, tkinter.XView, tkinter.YView):
@ -1874,9 +1872,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
# surprised if someone is using it.
show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ("tree", "headings"),
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = "",
yscrollcommand: tkinter._XYScrollCommand = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
xscrollcommand: str | Callable[[float, float], object] = "",
yscrollcommand: str | Callable[[float, float], object] = "",
) -> None:
"""Construct a Ttk Treeview with parent master.
@ -1911,9 +1909,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
selectmode: Literal["extended", "browse", "none"] = ...,
show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
yscrollcommand: tkinter._XYScrollCommand = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
yscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None:
"""Configure resources of a widget.
@ -1974,7 +1972,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
width: int = ...,
minwidth: int = ...,
stretch: bool = ...,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
# id is read-only
) -> _TreeviewColumnDict | None: ...
def delete(self, *items: str | int) -> None:
@ -2044,8 +2042,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
option: None = None,
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
anchor: tkinter._Anchor = ...,
image: tkinter._Image | str = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
command: str | Callable[[], object] = ...,
) -> None: ...
# Internal Method. Leave untyped:
@ -2094,7 +2092,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
*,
id: str | int = ..., # same as iid
text: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
values: list[Any] | tuple[Any, ...] = ...,
open: bool = ...,
tags: str | list[str] | tuple[str, ...] = ...,
@ -2142,7 +2140,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
option: None = None,
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
values: list[Any] | tuple[Any, ...] | Literal[""] = ...,
open: bool = ...,
tags: str | list[str] | tuple[str, ...] = ...,
@ -2259,7 +2257,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
foreground: str = ...,
background: str = ...,
font: _FontDescription = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
) -> _TreeviewTagDict | MaybeNone: ... # can be None but annoying to check
@overload
def tag_has(self, tagname: str, item: None = None) -> tuple[str, ...]:
@ -2292,18 +2290,18 @@ class LabeledScale(Frame):
from_: float = 0,
to: float = 10,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
border: float | str = ...,
borderwidth: float | str = ...,
class_: str = "",
compound: Literal["top", "bottom"] = "top",
cursor: tkinter._Cursor = "",
height: tkinter._ScreenUnits = 0,
height: float | str = 0,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
width: tkinter._ScreenUnits = 0,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: float | str = 0,
) -> None:
"""Construct a horizontal LabeledScale with parent master, a
variable to be associated with the Ttk Scale widget and its range.

View file

@ -467,8 +467,8 @@ class CellType:
cell_contents: Any
_YieldT_co = TypeVar("_YieldT_co", covariant=True)
_SendT_contra = TypeVar("_SendT_contra", contravariant=True)
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True)
_SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None)
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True, default=None)
@final
class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
@ -561,8 +561,12 @@ class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
def __class_getitem__(cls, item: Any, /) -> GenericAlias:
"""See PEP 585"""
# Non-default variations to accommodate coroutines
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)
@final
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
__name__: str
__qualname__: str
@property
@ -571,8 +575,13 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
@property
def cr_code(self) -> CodeType: ...
@property
def cr_frame(self) -> FrameType: ...
if sys.version_info >= (3, 12):
@property
def cr_frame(self) -> FrameType | None: ...
else:
@property
def cr_frame(self) -> FrameType: ...
@property
def cr_running(self) -> bool: ...
@property
@ -584,10 +593,10 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
def close(self) -> None:
"""close() -> raise GeneratorExit inside coroutine."""
def __await__(self) -> Generator[Any, None, _ReturnT_co]:
def __await__(self) -> Generator[Any, None, _ReturnT_nd_co]:
"""Return an iterator to be used in await expression."""
def send(self, arg: _SendT_contra, /) -> _YieldT_co:
def send(self, arg: _SendT_nd_contra, /) -> _YieldT_co:
"""send(arg) -> send 'arg' into coroutine,
return next iterated value or raise StopIteration.
"""
@ -963,15 +972,24 @@ if sys.version_info >= (3, 10):
@property
def __parameters__(self) -> tuple[Any, ...]:
"""Type variables in the types.UnionType."""
def __or__(self, value: Any, /) -> UnionType:
# `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`).
# Normally we'd express this using the return type of `_SpecialForm.__ror__`,
# but because `UnionType.__or__` accepts `Any`, type checkers will use
# the return type of `UnionType.__or__` to infer the result of this operation
# rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any`
# in the return type of `UnionType.__(r)or__`.
def __or__(self, value: Any, /) -> UnionType | Any:
"""Return self|value."""
def __ror__(self, value: Any, /) -> UnionType:
def __ror__(self, value: Any, /) -> UnionType | Any:
"""Return value|self."""
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
# you can only subscript a `UnionType` instance if at least one of the elements
# in the union is a generic alias instance that has a non-empty `__parameters__`
def __getitem__(self, parameters: Any) -> object:
"""Return self[key]."""
if sys.version_info >= (3, 13):
@final

View file

@ -61,6 +61,7 @@ __all__ = [
"AsyncIterator",
"Awaitable",
"BinaryIO",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
@ -129,9 +130,6 @@ __all__ = [
"runtime_checkable",
]
if sys.version_info < (3, 14):
__all__ += ["ByteString"]
if sys.version_info >= (3, 14):
__all__ += ["evaluate_forward_ref"]
@ -949,7 +947,7 @@ class Awaitable(Protocol[_T_co]):
@abstractmethod
def __await__(self) -> Generator[Any, Any, _T_co]: ...
# Non-default variations to accommodate couroutines, and `AwaitableGenerator` having a 4th type parameter.
# Non-default variations to accommodate coroutines, and `AwaitableGenerator` having a 4th type parameter.
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)
@ -1457,8 +1455,7 @@ class TextIO(IO[str]):
@abstractmethod
def __enter__(self) -> TextIO: ...
if sys.version_info < (3, 14):
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
# Functions