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

View file

@ -17,7 +17,8 @@ from datetime import time
t = time(12, 0, 0) t = time(12, 0, 0)
t = replace(t, minute=30) 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 ## The `__replace__` protocol
@ -47,7 +48,8 @@ b = a.__replace__(x=3, y=4)
reveal_type(b) # revealed: Point reveal_type(b) # revealed: Point
b = replace(a, x=3, y=4) 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: A call to `replace` does not require all keyword arguments:
@ -57,7 +59,8 @@ c = a.__replace__(y=4)
reveal_type(c) # revealed: Point reveal_type(c) # revealed: Point
d = replace(a, y=4) 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: Invalid calls to `__replace__` or `replace` will raise an error:

View file

@ -4403,8 +4403,8 @@ impl KnownClass {
KnownClassDisplay { db, class: self } KnownClassDisplay { db, class: self }
} }
/// Lookup a [`KnownClass`] in typeshed and return a [`Type`] /// Lookup a [`KnownClass`] in typeshed and return a [`Type`] representing all possible instances of
/// representing all possible instances of the class. /// 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. /// 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<'_> { pub(crate) fn to_instance(self, db: &dyn Db) -> Type<'_> {
@ -4414,6 +4414,14 @@ impl KnownClass {
.unwrap_or_else(Type::unknown) .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`] /// Lookup a generic [`KnownClass`] in typeshed and return a [`Type`]
/// representing a specialization of that class. /// 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`, // If type arguments are supplied to `(Async)Iterable`, `(Async)Iterator`,
// `(Async)Generator` or `(Async)GeneratorType` in the return annotation, // `(Async)Generator` or `(Async)GeneratorType` in the return annotation,
// we should iterate over the `yield` expressions and `return` statements in the function // we should iterate over the `yield` expressions and `return` statements
// to check that they are consistent with the type arguments provided. // 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 { let inferred_return = if function.is_async {
KnownClass::AsyncGeneratorType KnownClass::AsyncGeneratorType
} else { } else {
@ -1932,7 +1934,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
}; };
if !inferred_return if !inferred_return
.to_instance(self.db()) .to_instance_unknown(self.db())
.is_assignable_to(self.db(), expected_ty) .is_assignable_to(self.db(), expected_ty)
{ {
report_invalid_generator_function_return_type( 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 import sys
from abc import abstractmethod from abc import abstractmethod
from types import MappingProxyType from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035 from typing import ( # noqa: Y022,Y038,UP035,Y057
AbstractSet as Set, AbstractSet as Set,
AsyncGenerator as AsyncGenerator, AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable, AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator, AsyncIterator as AsyncIterator,
Awaitable as Awaitable, Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable, Callable as Callable,
ClassVar, ClassVar,
Collection as Collection, Collection as Collection,
@ -64,12 +65,8 @@ __all__ = [
"ValuesView", "ValuesView",
"Sequence", "Sequence",
"MutableSequence", "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): if sys.version_info >= (3, 12):
__all__ += ["Buffer"] __all__ += ["Buffer"]

View file

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

View file

@ -57,34 +57,34 @@ _TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
@final @final
class TkappType: class TkappType:
# Please keep in sync with tkinter.Tk # 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 call(self, command: Any, /, *args: Any) -> Any: ...
def createcommand(self, name, func, /): ... def createcommand(self, name: str, func, /): ...
if sys.platform != "win32": if sys.platform != "win32":
def createfilehandler(self, file, mask, func, /): ... def createfilehandler(self, file, mask: int, func, /): ...
def deletefilehandler(self, file, /): ... def deletefilehandler(self, file, /) -> None: ...
def createtimerhandler(self, milliseconds, func, /): ... def createtimerhandler(self, milliseconds: int, func, /): ...
def deletecommand(self, name, /): ... def deletecommand(self, name: str, /): ...
def dooneevent(self, flags: int = 0, /): ... def dooneevent(self, flags: int = 0, /): ...
def eval(self, script: str, /) -> str: ... def eval(self, script: str, /) -> str: ...
def evalfile(self, fileName, /): ... def evalfile(self, fileName: str, /): ...
def exprboolean(self, s, /): ... def exprboolean(self, s: str, /): ...
def exprdouble(self, s, /): ... def exprdouble(self, s: str, /): ...
def exprlong(self, s, /): ... def exprlong(self, s: str, /): ...
def exprstring(self, s, /): ... def exprstring(self, s: str, /): ...
def getboolean(self, arg, /): ... def getboolean(self, arg, /) -> bool: ...
def getdouble(self, arg, /): ... def getdouble(self, arg, /) -> float: ...
def getint(self, arg, /): ... def getint(self, arg, /) -> int: ...
def getvar(self, *args, **kwargs): ... def getvar(self, *args, **kwargs): ...
def globalgetvar(self, *args, **kwargs): ... def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ... def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ... def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self) -> int: ... def interpaddr(self) -> int: ...
def loadtk(self) -> None: ... def loadtk(self) -> None: ...
def mainloop(self, threshold: int = 0, /): ... def mainloop(self, threshold: int = 0, /) -> None: ...
def quit(self): ... def quit(self) -> None: ...
def record(self, script, /): ... def record(self, script: str, /): ...
def setvar(self, *ags, **kwargs): ... def setvar(self, *ags, **kwargs): ...
if sys.version_info < (3, 11): if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.") @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 splitlist(self, arg, /): ...
def unsetvar(self, *args, **kwargs): ... def unsetvar(self, *args, **kwargs): ...
def wantobjects(self, *args, **kwargs): ... def wantobjects(self, *args, **kwargs): ...
def willdispatch(self): ... def willdispatch(self) -> None: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def gettrace(self, /) -> _TkinterTraceFunc | None: def gettrace(self, /) -> _TkinterTraceFunc | None:
"""Get the tracing function.""" """Get the tracing function."""
@ -164,10 +164,10 @@ else:
if not None, then pass -use to wish 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.""" """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. """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. 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.""" """Tools to analyze tasks running in asyncio programs."""
import sys
from collections.abc import Iterable from collections.abc import Iterable
from enum import Enum from enum import Enum
from typing import NamedTuple, SupportsIndex, type_check_only 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]]: ... 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: def display_awaited_by_tasks_table(pid: SupportsIndex) -> None:
"""Build and print a table of all pending tasks under `pid`.""" """Build and print a table of all pending tasks under `pid`."""

View file

@ -4153,7 +4153,14 @@ def open(
opener: _Opener | None = None, opener: _Opener | None = None,
) -> IO[Any]: ... ) -> IO[Any]: ...
def ord(c: str | bytes | bytearray, /) -> int: 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 @type_check_only
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T_contra]): ... class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T_contra]): ...
@ -4451,7 +4458,7 @@ def __import__(
name: str, name: str,
globals: Mapping[str, object] | None = None, globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None, locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] = (), fromlist: Sequence[str] | None = (),
level: int = 0, level: int = 0,
) -> types.ModuleType: ) -> types.ModuleType:
"""Import a module. """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 empty(self) -> bool: ...
def full(self) -> bool: ... def full(self) -> bool: ...
def qsize(self) -> int: ... def qsize(self) -> int: ...
def put( if sys.version_info >= (3, 14):
self, def put(
obj: object, self,
timeout: SupportsIndex | None = None, obj: object,
*, block: bool = True,
unbounditems: _AnyUnbound | None = None, timeout: SupportsIndex | None = None,
_delay: float = 0.01, *,
) -> None: unbounditems: _AnyUnbound | None = None,
"""Add the object to the queue. _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 For most objects, the object received through Queue.get() will
be a new one, equivalent to the original and not sharing any be a new one, equivalent to the original and not sharing any
actual underlying data. The notable exceptions include actual underlying data. The notable exceptions include
cross-interpreter types (like Queue) and memoryview, where the cross-interpreter types (like Queue) and memoryview, where the
underlying data is actually shared. Furthermore, some types underlying data is actually shared. Furthermore, some types
can be sent through a queue more efficiently than others. This can be sent through a queue more efficiently than others. This
group includes various immutable types like int, str, bytes, and group includes various immutable types like int, str, bytes, and
tuple (if the items are likewise efficiently shareable). See interpreters.is_shareable(). tuple (if the items are likewise efficiently shareable). See interpreters.is_shareable().
"unbounditems" controls the behavior of Queue.get() for the given "unbounditems" controls the behavior of Queue.get() for the given
object if the current interpreter (calling put()) is later object if the current interpreter (calling put()) is later
destroyed. destroyed.
If "unbounditems" is None (the default) then it uses the If "unbounditems" is None (the default) then it uses the
queue's default, set with create_queue(), queue's default, set with create_queue(),
which is usually UNBOUND. which is usually UNBOUND.
If "unbounditems" is UNBOUND_ERROR then get() will raise an If "unbounditems" is UNBOUND_ERROR then get() will raise an
ItemInterpreterDestroyed exception if the original interpreter ItemInterpreterDestroyed exception if the original interpreter
has been destroyed. This does not otherwise affect the queue; has been destroyed. This does not otherwise affect the queue;
the next call to put() will work like normal, returning the next the next call to put() will work like normal, returning the next
item in the queue. item in the queue.
If "unbounditems" is UNBOUND_REMOVE then the item will be removed If "unbounditems" is UNBOUND_REMOVE then the item will be removed
from the queue as soon as the original interpreter is destroyed. from the queue as soon as the original interpreter is destroyed.
Be aware that this will introduce an imbalance between put() Be aware that this will introduce an imbalance between put()
and get() calls. and get() calls.
If "unbounditems" is UNBOUND then it is returned by get() in place If "unbounditems" is UNBOUND then it is returned by get() in place
of the unbound item. 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 put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ...
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: if sys.version_info >= (3, 14):
"""Return the next object from the queue. 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 If the next item's original interpreter has been destroyed
then the "next object" is determined by the value of the then the "next object" is determined by the value of the
"unbounditems" argument to put(). "unbounditems" argument to put().
""" """
else:
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
def get_nowait(self) -> object: def get_nowait(self) -> object:
"""Return the next object from the channel. """Return the next object from the channel.

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ class _Database(MutableMapping[bytes, bytes]):
def __enter__(self) -> Self: ... def __enter__(self) -> Self: ...
def __exit__(self, *args: Unused) -> None: ... 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. """Open a dbm.sqlite3 database and return the dbm object.
The 'filename' parameter is the name of the database file. The 'filename' parameter is the name of the database file.

View file

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

View file

@ -135,6 +135,7 @@ if sys.platform == "darwin":
ESHLIBVERS: Final[int] ESHLIBVERS: Final[int]
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
EQFULL: Final[int] EQFULL: Final[int]
ENOTCAPABLE: Final[int] # available starting with 3.11.1
if sys.platform != "darwin": if sys.platform != "darwin":
EDEADLOCK: Final[int] 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. 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: if sys.version_info >= (3, 14):
"""Enable the fault handler.""" 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: def is_enabled() -> bool:
"""Check if the handler is enabled.""" """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. set_debug() -- Set debugging flags.
get_debug() -- Get debugging flags. get_debug() -- Get debugging flags.
set_threshold() -- Set the collection thresholds. 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. get_objects() -- Return a list of all objects tracked by the collector.
is_tracked() -- Returns true if a given object is tracked. is_tracked() -- Returns true if a given object is tracked.
is_finalized() -- Returns true if a given object has been already finalized. 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: ' prompt: Written on stream to ask for the input. Default: 'Password: '
stream: A writable file object to display the prompt. Defaults to stream: A writable file object to display the prompt. Defaults to
the tty. If no tty is available defaults to sys.stderr. 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 echo_char: A single ASCII character to mask input (e.g., '*').
hidden. If None, input is hidden.
Returns: Returns:
The seKr3t input. The seKr3t input.
Raises: Raises:

View file

@ -37,7 +37,7 @@ if sys.version_info >= (3, 11):
""" """
@overload @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: ... def files(package: Anchor | None = None) -> Traversable: ...
else: else:

View file

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

View file

@ -467,8 +467,8 @@ class CellType:
cell_contents: Any cell_contents: Any
_YieldT_co = TypeVar("_YieldT_co", covariant=True) _YieldT_co = TypeVar("_YieldT_co", covariant=True)
_SendT_contra = TypeVar("_SendT_contra", contravariant=True) _SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None)
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True) _ReturnT_co = TypeVar("_ReturnT_co", covariant=True, default=None)
@final @final
class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]): 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: def __class_getitem__(cls, item: Any, /) -> GenericAlias:
"""See PEP 585""" """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 @final
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]): class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
__name__: str __name__: str
__qualname__: str __qualname__: str
@property @property
@ -571,8 +575,13 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
@property @property
def cr_code(self) -> CodeType: ... def cr_code(self) -> CodeType: ...
@property if sys.version_info >= (3, 12):
def cr_frame(self) -> FrameType: ... @property
def cr_frame(self) -> FrameType | None: ...
else:
@property
def cr_frame(self) -> FrameType: ...
@property @property
def cr_running(self) -> bool: ... def cr_running(self) -> bool: ...
@property @property
@ -584,10 +593,10 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
def close(self) -> None: def close(self) -> None:
"""close() -> raise GeneratorExit inside coroutine.""" """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.""" """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, """send(arg) -> send 'arg' into coroutine,
return next iterated value or raise StopIteration. return next iterated value or raise StopIteration.
""" """
@ -963,15 +972,24 @@ if sys.version_info >= (3, 10):
@property @property
def __parameters__(self) -> tuple[Any, ...]: def __parameters__(self) -> tuple[Any, ...]:
"""Type variables in the types.UnionType.""" """Type variables in the types.UnionType."""
# `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`).
def __or__(self, value: Any, /) -> UnionType: # 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.""" """Return self|value."""
def __ror__(self, value: Any, /) -> UnionType: def __ror__(self, value: Any, /) -> UnionType | Any:
"""Return value|self.""" """Return value|self."""
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ... 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): if sys.version_info >= (3, 13):
@final @final

View file

@ -61,6 +61,7 @@ __all__ = [
"AsyncIterator", "AsyncIterator",
"Awaitable", "Awaitable",
"BinaryIO", "BinaryIO",
"ByteString",
"Callable", "Callable",
"ChainMap", "ChainMap",
"ClassVar", "ClassVar",
@ -129,9 +130,6 @@ __all__ = [
"runtime_checkable", "runtime_checkable",
] ]
if sys.version_info < (3, 14):
__all__ += ["ByteString"]
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
__all__ += ["evaluate_forward_ref"] __all__ += ["evaluate_forward_ref"]
@ -949,7 +947,7 @@ class Awaitable(Protocol[_T_co]):
@abstractmethod @abstractmethod
def __await__(self) -> Generator[Any, Any, _T_co]: ... 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) _SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True) _ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)
@ -1457,8 +1455,7 @@ class TextIO(IO[str]):
@abstractmethod @abstractmethod
def __enter__(self) -> TextIO: ... 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 # Functions