From 464df8684f4dccd3e0f3b221a4d7794d07a65804 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 13 Nov 2026 16:13:13 +0100 Subject: [PATCH 1/3] [stdlib] Replace `float` with `FloatInt` Keep `float` in the following cases: - If it's already in an union with `int`. - Return types (also in compound return types). - Return types of `Callable` types. - Type arguments of base classes. - Type var constraints. This was mainly generated using a codemod, and manually verified. Manual changes: - Reordered `float`/`int` unions to a consistent order. - Change a few instances of `FloatInt` to `float | int`. - `statistics._Number` - Change a few instances of `FloatInt` to `float`: - `time._SupportsFloatOrIndex` (is in union with `SupportsIndex`) - Add `int` to constraints of `statistics._NumberT`. - Remove `# noqa: Y041` comments. - Update/remove a few outdated comments. Part of #16059 --- stdlib/_interpchannels.pyi | 6 +- stdlib/_lsprof.pyi | 12 +- stdlib/_queue.pyi | 5 +- stdlib/_remote_debugging.pyi | 11 +- stdlib/_socket.pyi | 6 +- stdlib/_sqlite3.pyi | 16 +- stdlib/_ssl.pyi | 4 +- stdlib/_thread.pyi | 16 +- stdlib/_typeshed/__init__.pyi | 2 +- stdlib/antigravity.pyi | 4 +- stdlib/array.pyi | 6 +- stdlib/ast.pyi | 2 +- stdlib/asyncio/base_events.pyi | 98 +- stdlib/asyncio/constants.pyi | 5 +- stdlib/asyncio/events.pyi | 98 +- stdlib/asyncio/sslproto.pyi | 3 +- stdlib/asyncio/staggered.pyi | 3 +- stdlib/asyncio/streams.pyi | 12 +- stdlib/asyncio/tasks.pyi | 17 +- stdlib/asyncio/timeouts.pyi | 9 +- stdlib/asyncio/trsock.pyi | 4 +- stdlib/asyncio/unix_events.pyi | 6 +- stdlib/asyncio/windows_events.pyi | 6 +- stdlib/asyncore.pyi | 8 +- stdlib/audioop.pyi | 7 +- stdlib/builtins.pyi | 51 +- stdlib/cmath.pyi | 11 +- stdlib/colorsys.pyi | 19 +- stdlib/concurrent/futures/_base.pyi | 16 +- stdlib/concurrent/interpreters/_queues.pyi | 9 +- stdlib/datetime.pyi | 37 +- stdlib/dbm/sqlite3.pyi | 2 +- stdlib/decimal.pyi | 11 +- stdlib/difflib.pyi | 5 +- stdlib/email/utils.pyi | 4 +- stdlib/faulthandler.pyi | 6 +- stdlib/fractions.pyi | 45 +- stdlib/ftplib.pyi | 14 +- stdlib/gzip.pyi | 18 +- stdlib/http/client.pyi | 16 +- stdlib/http/cookiejar.pyi | 4 +- stdlib/http/server.pyi | 4 +- stdlib/imaplib.pyi | 24 +- stdlib/itertools.pyi | 2 +- stdlib/json/encoder.pyi | 3 +- stdlib/linecache.pyi | 3 +- stdlib/locale.pyi | 7 +- stdlib/logging/__init__.pyi | 10 +- stdlib/logging/handlers.pyi | 20 +- stdlib/mailbox.pyi | 4 +- stdlib/marshal.pyi | 5 +- stdlib/math/__init__.pyi | 14 +- stdlib/multiprocessing/connection.pyi | 6 +- stdlib/multiprocessing/context.pyi | 3 +- stdlib/multiprocessing/dummy/connection.pyi | 3 +- stdlib/multiprocessing/managers.pyi | 8 +- stdlib/multiprocessing/pool.pyi | 9 +- stdlib/multiprocessing/popen_fork.pyi | 3 +- stdlib/multiprocessing/popen_spawn_win32.pyi | 3 +- stdlib/multiprocessing/process.pyi | 3 +- stdlib/multiprocessing/queues.pyi | 5 +- stdlib/multiprocessing/resource_sharer.pyi | 3 +- stdlib/multiprocessing/shared_memory.pyi | 2 +- stdlib/multiprocessing/sharedctypes.pyi | 3 +- stdlib/multiprocessing/synchronize.pyi | 13 +- stdlib/multiprocessing/util.pyi | 4 +- stdlib/nntplib.pyi | 6 +- stdlib/os/__init__.pyi | 5 +- stdlib/plistlib.pyi | 10 +- stdlib/poplib.pyi | 10 +- stdlib/profiling/sampling/gecko_collector.pyi | 16 +- .../profiling/sampling/heatmap_collector.pyi | 10 +- stdlib/profiling/sampling/stack_collector.pyi | 20 +- stdlib/pstats.pyi | 12 +- stdlib/pyexpat/__init__.pyi | 6 +- stdlib/queue.pyi | 6 +- stdlib/random.pyi | 44 +- stdlib/sched.pyi | 16 +- stdlib/select.pyi | 12 +- stdlib/selectors.pyi | 12 +- stdlib/signal.pyi | 6 +- stdlib/smtplib.pyi | 14 +- stdlib/socket.pyi | 6 +- stdlib/socketserver.pyi | 10 +- stdlib/sqlite3/__init__.pyi | 10 +- stdlib/sqlite3/dbapi2.pyi | 7 +- stdlib/ssl.pyi | 4 +- stdlib/statistics.pyi | 38 +- stdlib/subprocess.pyi | 66 +- stdlib/sunau.pyi | 4 +- stdlib/sys/__init__.pyi | 4 +- stdlib/tarfile.pyi | 8 +- stdlib/telnetlib.pyi | 9 +- stdlib/threading.pyi | 28 +- stdlib/time.pyi | 9 +- stdlib/timeit.pyi | 5 +- stdlib/tkinter/__init__.pyi | 1325 +++++++++-------- stdlib/tkinter/simpledialog.pyi | 7 +- stdlib/tkinter/ttk.pyi | 190 +-- stdlib/turtle.pyi | 207 +-- stdlib/unittest/mock.pyi | 8 +- stdlib/unittest/result.pyi | 6 +- stdlib/urllib/request.pyi | 24 +- stdlib/wave.pyi | 4 +- stdlib/wsgiref/handlers.pyi | 4 +- stdlib/xdrlib.pyi | 5 +- stdlib/xmlrpc/client.pyi | 6 +- 107 files changed, 1529 insertions(+), 1468 deletions(-) diff --git a/stdlib/_interpchannels.pyi b/stdlib/_interpchannels.pyi index a631a6f16616..c31bb5e34515 100644 --- a/stdlib/_interpchannels.pyi +++ b/stdlib/_interpchannels.pyi @@ -1,4 +1,4 @@ -from _typeshed import structseq +from _typeshed import FloatInt, structseq from typing import Any, Final, Literal, SupportsIndex, final from typing_extensions import Buffer, Self @@ -76,8 +76,8 @@ def create(unboundop: Literal[1, 2, 3]) -> ChannelID: ... def destroy(cid: SupportsIndex) -> None: ... def list_all() -> list[ChannelID]: ... def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ... -def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ... -def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ... +def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: FloatInt | None = None) -> None: ... +def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: FloatInt | None = None) -> None: ... def recv(cid: SupportsIndex, default: object = ...) -> tuple[Any, Literal[1, 2, 3]]: ... def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ... def get_count(cid: SupportsIndex) -> int: ... diff --git a/stdlib/_lsprof.pyi b/stdlib/_lsprof.pyi index d04c2a74ee07..32b0369b01a5 100644 --- a/stdlib/_lsprof.pyi +++ b/stdlib/_lsprof.pyi @@ -1,4 +1,4 @@ -from _typeshed import structseq +from _typeshed import FloatInt, structseq from collections.abc import Callable from types import CodeType from typing import Any, Final, final @@ -7,7 +7,7 @@ from typing_extensions import disjoint_base @disjoint_base class Profiler: def __init__( - self, timer: Callable[[], float] | None = None, timeunit: float = 0.0, subcalls: bool = True, builtins: bool = True + self, timer: Callable[[], float] | None = None, timeunit: FloatInt = 0.0, subcalls: bool = True, builtins: bool = True ) -> None: ... def getstats(self) -> list[profiler_entry]: ... def enable(self, subcalls: bool = True, builtins: bool = True) -> None: ... @@ -20,8 +20,8 @@ class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, floa code: CodeType | str callcount: int reccallcount: int - totaltime: float - inlinetime: float + totaltime: FloatInt + inlinetime: FloatInt calls: list[profiler_subentry] @final @@ -30,5 +30,5 @@ class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, f code: CodeType | str callcount: int reccallcount: int - totaltime: float - inlinetime: float + totaltime: FloatInt + inlinetime: FloatInt diff --git a/stdlib/_queue.pyi b/stdlib/_queue.pyi index edd484a9a71a..1c7125f102fd 100644 --- a/stdlib/_queue.pyi +++ b/stdlib/_queue.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from types import GenericAlias from typing import Any, Generic, TypeVar from typing_extensions import disjoint_base @@ -10,9 +11,9 @@ class Empty(Exception): ... class SimpleQueue(Generic[_T]): def __init__(self) -> None: ... def empty(self) -> bool: ... - def get(self, block: bool = True, timeout: float | None = None) -> _T: ... + def get(self, block: bool = True, timeout: FloatInt | None = None) -> _T: ... def get_nowait(self) -> _T: ... - def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... + def put(self, item: _T, block: bool = True, timeout: FloatInt | None = None) -> None: ... def put_nowait(self, item: _T) -> None: ... def qsize(self) -> int: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... diff --git a/stdlib/_remote_debugging.pyi b/stdlib/_remote_debugging.pyi index 1e9f411dd130..25c89dec2697 100644 --- a/stdlib/_remote_debugging.pyi +++ b/stdlib/_remote_debugging.pyi @@ -1,11 +1,11 @@ -from _typeshed import StrOrBytesPath, structseq +from _typeshed import FloatInt, StrOrBytesPath, structseq from collections.abc import Callable from typing import Final, TypeAlias, final from typing_extensions import Self _Location: TypeAlias = tuple[int, int, int, int] | LocationInfo | None _Frame: TypeAlias = tuple[str, _Location, str, int | None] | FrameInfo -_Stats: TypeAlias = dict[str, int | float] +_Stats: TypeAlias = dict[str, float | int] PROCESS_VM_READV_SUPPORTED: Final[int] THREAD_STATUS_GIL_REQUESTED: Final[int] @@ -161,7 +161,12 @@ class BinaryWriter: def limit_reached(self) -> bool: ... def write_sample(self, stack_frames: list[InterpreterInfo], timestamp_us: int) -> None: ... def set_stats( - self, /, duration_sec: float, sample_rate: float, error_rate: float | None = None, missed_samples: float | None = None + self, + /, + duration_sec: FloatInt, + sample_rate: FloatInt, + error_rate: FloatInt | None = None, + missed_samples: FloatInt | None = None, ) -> None: ... def finalize(self) -> None: ... def close(self) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 40f76715e394..cebce91d3b78 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, WriteableBuffer +from _typeshed import FloatInt, ReadableBuffer, WriteableBuffer from collections.abc import Iterable from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout from typing import Any, Final, SupportsIndex, TypeAlias, overload @@ -906,7 +906,7 @@ class socket: ) -> int: ... def setblocking(self, flag: bool, /) -> None: ... - def settimeout(self, value: float | None, /) -> None: ... + def settimeout(self, value: FloatInt | None, /) -> None: ... @overload def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer, /) -> None: ... @@ -948,7 +948,7 @@ def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str: ... def getdefaulttimeout() -> float | None: ... # F811: "Redefinition of unused `timeout`" -def setdefaulttimeout(timeout: float | None, /) -> None: ... +def setdefaulttimeout(timeout: FloatInt | None, /) -> None: ... if sys.platform != "win32": def sethostname(name: str, /) -> None: ... diff --git a/stdlib/_sqlite3.pyi b/stdlib/_sqlite3.pyi index b6d96121afa9..6ad637936ba8 100644 --- a/stdlib/_sqlite3.pyi +++ b/stdlib/_sqlite3.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, StrOrBytesPath +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath from collections.abc import Callable from sqlite3 import ( Connection as Connection, @@ -26,7 +26,7 @@ if sys.version_info >= (3, 11): _T = TypeVar("_T") _ConnectionT = TypeVar("_ConnectionT", bound=Connection) -_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None +_SqliteData: TypeAlias = str | ReadableBuffer | float | int | None _Adapter: TypeAlias = Callable[[_T], _SqliteData] _Converter: TypeAlias = Callable[[bytes], Any] @@ -227,7 +227,7 @@ if sys.version_info >= (3, 12): @overload def connect( database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, @@ -239,7 +239,7 @@ if sys.version_info >= (3, 12): @overload def connect( database: StrOrBytesPath, - timeout: float, + timeout: FloatInt, detect_types: int, isolation_level: _IsolationLevel, check_same_thread: bool, @@ -252,7 +252,7 @@ if sys.version_info >= (3, 12): @overload def connect( database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, @@ -266,7 +266,7 @@ else: @overload def connect( database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, @@ -276,7 +276,7 @@ else: @overload def connect( database: StrOrBytesPath, - timeout: float, + timeout: FloatInt, detect_types: int, isolation_level: _IsolationLevel, check_same_thread: bool, @@ -287,7 +287,7 @@ else: @overload def connect( database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, diff --git a/stdlib/_ssl.pyi b/stdlib/_ssl.pyi index 29e50111b8b2..b5458ed2b539 100644 --- a/stdlib/_ssl.pyi +++ b/stdlib/_ssl.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, StrOrBytesPath +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath from collections.abc import Callable from ssl import ( SSLCertVerificationError as SSLCertVerificationError, @@ -47,7 +47,7 @@ class _CertInfo(TypedDict): caIssuers: NotRequired[tuple[str, ...] | None] crlDistributionPoints: NotRequired[tuple[str, ...] | None] -def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ... +def RAND_add(string: str | ReadableBuffer, entropy: FloatInt, /) -> None: ... def RAND_bytes(n: int, /) -> bytes: ... if sys.version_info < (3, 12): diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 823a91831ee3..22bc0f9068f1 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,6 +1,6 @@ import signal import sys -from _typeshed import structseq +from _typeshed import FloatInt, structseq from collections.abc import Callable from threading import Thread from types import TracebackType @@ -15,7 +15,7 @@ def _count() -> int: ... @final class RLock: - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... def release(self) -> None: ... __enter__ = acquire def __exit__( @@ -29,7 +29,7 @@ if sys.version_info >= (3, 13): class _ThreadHandle: ident: int - def join(self, timeout: float | None = None, /) -> None: ... + def join(self, timeout: FloatInt | None = None, /) -> None: ... def is_done(self) -> bool: ... def _set_done(self) -> None: ... @@ -39,11 +39,11 @@ if sys.version_info >= (3, 13): @final class lock: - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @deprecated("Obsolete synonym. Use `acquire()` instead.") - def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented + def acquire_lock(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... # undocumented @deprecated("Obsolete synonym. Use `release()` instead.") def release_lock(self) -> None: ... # undocumented @deprecated("Obsolete synonym. Use `locked()` instead.") @@ -57,11 +57,11 @@ if sys.version_info >= (3, 13): else: @final class LockType: - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @deprecated("Obsolete synonym. Use `acquire()` instead.") - def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented + def acquire_lock(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... # undocumented @deprecated("Obsolete synonym. Use `release()` instead.") def release_lock(self) -> None: ... # undocumented @deprecated("Obsolete synonym. Use `locked()` instead.") @@ -93,7 +93,7 @@ def allocate() -> LockType: ... # undocumented def get_ident() -> int: ... def stack_size(size: int = 0, /) -> int: ... -TIMEOUT_MAX: Final[float] +TIMEOUT_MAX: Final[FloatInt] def get_native_id() -> int: ... # only available on some platforms diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index f42be80abdc0..b61e89556374 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -58,7 +58,7 @@ Unused: TypeAlias = object # stable # for more information. MaybeNone: TypeAlias = Any # stable -# typeshed-internal type aliases to facilitate transition from +# typeshed-internal type alias to facilitate transition from # `float` to either `float | int` or `float`. When you encounter this type # alias, you are encouraged to replace it with the correct type. Please don't # use it outside typeshed. diff --git a/stdlib/antigravity.pyi b/stdlib/antigravity.pyi index 3986e7d1c9f2..091f668523e5 100644 --- a/stdlib/antigravity.pyi +++ b/stdlib/antigravity.pyi @@ -1,3 +1,3 @@ -from _typeshed import ReadableBuffer +from _typeshed import FloatInt, ReadableBuffer -def geohash(latitude: float, longitude: float, datedow: ReadableBuffer) -> None: ... +def geohash(latitude: FloatInt, longitude: FloatInt, datedow: ReadableBuffer) -> None: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 2c83146edbf0..08ae3cce486e 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite +from _typeshed import FloatInt, ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, MutableSequence from types import GenericAlias from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, TypeVar, overload @@ -16,7 +16,7 @@ else: _UnicodeTypeCode: TypeAlias = Literal["u"] _TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode -_T = TypeVar("_T", int, float, str) +_T = TypeVar("_T", float, int, str) if sys.version_info >= (3, 15): typecodes: tuple[str, ...] @@ -36,7 +36,7 @@ class array(MutableSequence[_T]): ) -> array[int]: ... @overload def __new__( - cls: type[array[float]], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., / + cls: type[array[float]], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[FloatInt] = ..., / ) -> array[float]: ... if sys.version_info >= (3, 13): @overload diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 000f84093604..ed8f2827edaf 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1107,7 +1107,7 @@ if sys.version_info >= (3, 14): **kwargs: Unpack[_Attributes], ) -> Self: ... -_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | EllipsisType | None +_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | complex | float | int | EllipsisType | None class Constant(expr): __match_args__ = ("value", "kind") diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 29ecbdf7feba..d212c87a48db 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -1,6 +1,6 @@ import ssl import sys -from _typeshed import FileDescriptorLike, ReadableBuffer, WriteableBuffer +from _typeshed import FileDescriptorLike, FloatInt, ReadableBuffer, WriteableBuffer from asyncio import _AwaitableLike, _CoroutineLike from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle, _TaskFactory from asyncio.futures import Future @@ -34,8 +34,8 @@ class Server(AbstractServer): protocol_factory: _ProtocolFactory, ssl_context: _SSLContext, backlog: int, - ssl_handshake_timeout: float | None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> None: ... else: def __init__( @@ -45,7 +45,7 @@ class Server(AbstractServer): protocol_factory: _ProtocolFactory, ssl_context: _SSLContext, backlog: int, - ssl_handshake_timeout: float | None, + ssl_handshake_timeout: FloatInt | None, ) -> None: ... if sys.version_info >= (3, 13): @@ -74,10 +74,10 @@ class BaseEventLoop(AbstractEventLoop): self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None ) -> Handle: ... def call_later( - self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None + self, delay: FloatInt, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None ) -> TimerHandle: ... def call_at( - self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None + self, when: FloatInt, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None ) -> TimerHandle: ... def time(self) -> float: ... # Future methods @@ -134,9 +134,9 @@ class BaseEventLoop(AbstractEventLoop): sock: None = None, local_addr: tuple[str, int] | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, all_errors: bool = False, ) -> tuple[Transport, _ProtocolT]: ... @@ -154,9 +154,9 @@ class BaseEventLoop(AbstractEventLoop): sock: socket, local_addr: None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, all_errors: bool = False, ) -> tuple[Transport, _ProtocolT]: ... @@ -175,9 +175,9 @@ class BaseEventLoop(AbstractEventLoop): sock: None = None, local_addr: tuple[str, int] | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @overload @@ -194,9 +194,9 @@ class BaseEventLoop(AbstractEventLoop): sock: socket, local_addr: None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... else: @@ -214,8 +214,8 @@ class BaseEventLoop(AbstractEventLoop): sock: None = None, local_addr: tuple[str, int] | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @overload @@ -232,8 +232,8 @@ class BaseEventLoop(AbstractEventLoop): sock: socket, local_addr: None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @@ -254,8 +254,8 @@ class BaseEventLoop(AbstractEventLoop): reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -273,8 +273,8 @@ class BaseEventLoop(AbstractEventLoop): reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -292,8 +292,8 @@ class BaseEventLoop(AbstractEventLoop): reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -311,8 +311,8 @@ class BaseEventLoop(AbstractEventLoop): reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... elif sys.version_info >= (3, 11): @@ -330,8 +330,8 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -348,8 +348,8 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -366,8 +366,8 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -384,8 +384,8 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... else: @@ -403,7 +403,7 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -420,7 +420,7 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -437,7 +437,7 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -454,7 +454,7 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @@ -467,8 +467,8 @@ class BaseEventLoop(AbstractEventLoop): *, server_side: bool = False, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> Transport | None: ... async def connect_accepted_socket( self, @@ -476,8 +476,8 @@ class BaseEventLoop(AbstractEventLoop): sock: socket, *, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... else: async def start_tls( @@ -488,7 +488,7 @@ class BaseEventLoop(AbstractEventLoop): *, server_side: bool = False, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, ) -> Transport | None: ... async def connect_accepted_socket( self, @@ -496,7 +496,7 @@ class BaseEventLoop(AbstractEventLoop): sock: socket, *, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... async def sock_sendfile( @@ -600,7 +600,7 @@ class BaseEventLoop(AbstractEventLoop): def get_debug(self) -> bool: ... def set_debug(self, enabled: bool) -> None: ... if sys.version_info >= (3, 12): - async def shutdown_default_executor(self, timeout: float | None = None) -> None: ... + async def shutdown_default_executor(self, timeout: FloatInt | None = None) -> None: ... else: async def shutdown_default_executor(self) -> None: ... diff --git a/stdlib/asyncio/constants.pyi b/stdlib/asyncio/constants.pyi index 5c6456b0e9c0..f232ac3750a5 100644 --- a/stdlib/asyncio/constants.pyi +++ b/stdlib/asyncio/constants.pyi @@ -1,14 +1,15 @@ import enum import sys +from _typeshed import FloatInt from typing import Final LOG_THRESHOLD_FOR_CONNLOST_WRITES: Final = 5 ACCEPT_RETRY_DELAY: Final = 1 DEBUG_STACK_DEPTH: Final = 10 -SSL_HANDSHAKE_TIMEOUT: float +SSL_HANDSHAKE_TIMEOUT: FloatInt SENDFILE_FALLBACK_READBUFFER_SIZE: Final = 262144 if sys.version_info >= (3, 11): - SSL_SHUTDOWN_TIMEOUT: float + SSL_SHUTDOWN_TIMEOUT: FloatInt FLOW_CONTROL_HIGH_WATER_SSL_READ: Final = 256 FLOW_CONTROL_HIGH_WATER_SSL_WRITE: Final = 512 if sys.version_info >= (3, 12): diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 4d1cf3138c7e..3f07525d7ea3 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -6,7 +6,7 @@ from _asyncio import ( get_event_loop as get_event_loop, get_running_loop as get_running_loop, ) -from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer +from _typeshed import FileDescriptorLike, FloatInt, ReadableBuffer, StrPath, Unused, WriteableBuffer from abc import ABCMeta, abstractmethod from collections.abc import Callable, Sequence from concurrent.futures import Executor @@ -89,7 +89,7 @@ class TimerHandle(Handle): __slots__ = ["_scheduled", "_when"] def __init__( self, - when: float, + when: FloatInt, callback: Callable[..., object], args: Sequence[Any], loop: AbstractEventLoop, @@ -126,7 +126,7 @@ class AbstractServer: async def wait_closed(self) -> None: ... class AbstractEventLoop: - slow_callback_duration: float + slow_callback_duration: FloatInt @abstractmethod def run_forever(self) -> None: ... @abstractmethod @@ -149,11 +149,11 @@ class AbstractEventLoop: ) -> Handle: ... @abstractmethod def call_later( - self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None + self, delay: FloatInt, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None ) -> TimerHandle: ... @abstractmethod def call_at( - self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None + self, when: FloatInt, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None ) -> TimerHandle: ... @abstractmethod def time(self) -> float: ... @@ -226,9 +226,9 @@ class AbstractEventLoop: sock: None = None, local_addr: tuple[str, int] | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @overload @@ -246,9 +246,9 @@ class AbstractEventLoop: sock: socket, local_addr: None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... else: @@ -267,8 +267,8 @@ class AbstractEventLoop: sock: None = None, local_addr: tuple[str, int] | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @overload @@ -286,8 +286,8 @@ class AbstractEventLoop: sock: socket, local_addr: None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - happy_eyeballs_delay: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + happy_eyeballs_delay: FloatInt | None = None, interleave: int | None = None, ) -> tuple[Transport, _ProtocolT]: ... @@ -309,8 +309,8 @@ class AbstractEventLoop: reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -329,8 +329,8 @@ class AbstractEventLoop: reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -349,8 +349,8 @@ class AbstractEventLoop: reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -369,8 +369,8 @@ class AbstractEventLoop: reuse_address: bool | None = None, reuse_port: bool | None = None, keep_alive: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... elif sys.version_info >= (3, 11): @@ -389,8 +389,8 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -408,8 +408,8 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -427,8 +427,8 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -446,8 +446,8 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... else: @@ -466,7 +466,7 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -484,7 +484,7 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -502,7 +502,7 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @overload @@ -520,7 +520,7 @@ class AbstractEventLoop: ssl: _SSLContext = None, reuse_address: bool | None = None, reuse_port: bool | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @@ -534,8 +534,8 @@ class AbstractEventLoop: *, server_side: bool = False, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> Transport | None: ... else: @abstractmethod @@ -547,7 +547,7 @@ class AbstractEventLoop: *, server_side: bool = False, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, ) -> Transport | None: ... if sys.version_info >= (3, 13): @@ -559,8 +559,8 @@ class AbstractEventLoop: sock: socket | None = None, backlog: int = 100, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, cleanup_socket: bool = True, ) -> Server: ... @@ -573,8 +573,8 @@ class AbstractEventLoop: sock: socket | None = None, backlog: int = 100, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... else: @@ -586,7 +586,7 @@ class AbstractEventLoop: sock: socket | None = None, backlog: int = 100, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, start_serving: bool = True, ) -> Server: ... @@ -597,8 +597,8 @@ class AbstractEventLoop: sock: socket, *, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... else: async def connect_accepted_socket( @@ -607,7 +607,7 @@ class AbstractEventLoop: sock: socket, *, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... if sys.version_info >= (3, 11): async def create_unix_connection( @@ -618,8 +618,8 @@ class AbstractEventLoop: ssl: _SSLContext = None, sock: socket | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... else: async def create_unix_connection( @@ -630,7 +630,7 @@ class AbstractEventLoop: ssl: _SSLContext = None, sock: socket | None = None, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, ) -> tuple[Transport, _ProtocolT]: ... @abstractmethod diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index 72b4ea449e86..fea355fdc436 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -1,5 +1,6 @@ import ssl import sys +from _typeshed import FloatInt from collections import deque from collections.abc import Callable from enum import Enum @@ -125,7 +126,7 @@ class SSLProtocol(_SSLProtocolBase): server_hostname: str | None = None, call_connection_made: bool = True, ssl_handshake_timeout: int | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> None: ... else: def __init__( diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index 3324777f4168..35669c64bffb 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from collections.abc import Awaitable, Callable, Iterable from typing import Any @@ -6,5 +7,5 @@ from . import events __all__ = ("staggered_race",) async def staggered_race( - coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None + coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: FloatInt | None, *, loop: events.AbstractEventLoop | None = None ) -> tuple[Any, int | None, list[Exception | None]]: ... diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 9e76c69d8732..296ba32dd271 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -1,6 +1,6 @@ import ssl import sys -from _typeshed import ReadableBuffer, StrPath +from _typeshed import FloatInt, ReadableBuffer, StrPath from collections.abc import Awaitable, Callable, Iterable, Sequence, Sized from types import ModuleType from typing import Any, Protocol, SupportsIndex, TypeAlias, type_check_only @@ -33,7 +33,7 @@ async def open_connection( port: int | str | None = None, *, limit: int = 65536, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, **kwds: Any, ) -> tuple[StreamReader, StreamWriter]: ... async def start_server( @@ -42,7 +42,7 @@ async def start_server( port: int | str | None = None, *, limit: int = 65536, - ssl_handshake_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, **kwds: Any, ) -> Server: ... @@ -91,12 +91,12 @@ class StreamWriter: sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, ) -> None: ... elif sys.version_info >= (3, 11): async def start_tls( - self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None + self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: FloatInt | None = None ) -> None: ... if sys.version_info >= (3, 13): diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 66c31f15e6fb..abe88ce6b063 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -7,6 +7,7 @@ from _asyncio import ( _register_task as _register_task, _unregister_task as _unregister_task, ) +from _typeshed import FloatInt from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only @@ -89,10 +90,10 @@ if sys.version_info >= (3, 13): @type_check_only class _SyncAndAsyncIterator(Iterator[Coroutine[Any, Any, _T]], AsyncIterator[Future[_T]], Protocol[_T]): ... - def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[_T]: ... + def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: FloatInt | None = None) -> _SyncAndAsyncIterator[_T]: ... else: - def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... + def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: FloatInt | None = None) -> Iterator[Future[_T]]: ... @overload def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap] @@ -220,25 +221,25 @@ def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventL def shield(arg: _FutureLike[_T]) -> Future[_T]: ... @overload -async def sleep(delay: float) -> None: ... +async def sleep(delay: FloatInt) -> None: ... @overload -async def sleep(delay: float, result: _T) -> _T: ... +async def sleep(delay: FloatInt, result: _T) -> _T: ... -async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... +async def wait_for(fut: _FutureLike[_T], timeout: FloatInt | None) -> _T: ... if sys.version_info >= (3, 11): async def wait( - fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" + fs: Iterable[_FT], *, timeout: FloatInt | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[_FT], set[_FT]]: ... else: @overload async def wait( # type: ignore[overload-overlap] - fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" + fs: Iterable[_FT], *, timeout: FloatInt | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[_FT], set[_FT]]: ... @overload async def wait( - fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" + fs: Iterable[Awaitable[_T]], *, timeout: FloatInt | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... if sys.version_info >= (3, 12): diff --git a/stdlib/asyncio/timeouts.pyi b/stdlib/asyncio/timeouts.pyi index 668cccbfe8b1..579145999e0d 100644 --- a/stdlib/asyncio/timeouts.pyi +++ b/stdlib/asyncio/timeouts.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from types import TracebackType from typing import final from typing_extensions import Self @@ -7,14 +8,14 @@ __all__ = ("Timeout", "timeout", "timeout_at") @final class Timeout: - def __init__(self, when: float | None) -> None: ... + def __init__(self, when: FloatInt | None) -> None: ... def when(self) -> float | None: ... - def reschedule(self, when: float | None) -> None: ... + def reschedule(self, when: FloatInt | None) -> None: ... def expired(self) -> bool: ... async def __aenter__(self) -> Self: ... async def __aexit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... -def timeout(delay: float | None) -> Timeout: ... -def timeout_at(when: float | None) -> Timeout: ... +def timeout(delay: FloatInt | None) -> Timeout: ... +def timeout_at(when: FloatInt | None) -> Timeout: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index d2e972fee49c..af296be21fa9 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,6 +1,6 @@ import socket import sys -from _typeshed import ReadableBuffer +from _typeshed import FloatInt, ReadableBuffer from builtins import type as Type # alias to avoid name clashes with property named "type" from collections.abc import Iterable from types import TracebackType @@ -41,7 +41,7 @@ class TransportSocket: def getpeername(self) -> _RetAddress: ... def getsockname(self) -> _RetAddress: ... def getsockbyname(self) -> Never: ... # This method doesn't exist on socket, yet is passed through? - def settimeout(self, value: float | None) -> None: ... + def settimeout(self, value: FloatInt | None) -> None: ... def gettimeout(self) -> float | None: ... def setblocking(self, flag: bool) -> None: ... if sys.version_info < (3, 11): diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index 368cac38302f..44823ed433a0 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -1,6 +1,6 @@ import sys import types -from _typeshed import StrPath +from _typeshed import FloatInt, StrPath from abc import ABCMeta, abstractmethod from collections.abc import Callable from socket import socket @@ -161,8 +161,8 @@ if sys.platform != "win32": sock: socket | None = None, backlog: int = 100, ssl: _SSLContext = None, - ssl_handshake_timeout: float | None = None, - ssl_shutdown_timeout: float | None = None, + ssl_handshake_timeout: FloatInt | None = None, + ssl_shutdown_timeout: FloatInt | None = None, start_serving: bool = True, cleanup_socket: bool = True, ) -> Server: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index a2428e425f2f..ccc5bffdb2df 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,6 +1,6 @@ import socket import sys -from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer +from _typeshed import FloatInt, Incomplete, ReadableBuffer, WriteableBuffer from collections.abc import Callable from typing import IO, Any, ClassVar, Final from typing_extensions import Never @@ -44,8 +44,8 @@ if sys.platform == "win32": INFINITE: Final = 0xFFFFFFFF ERROR_CONNECTION_REFUSED: Final = 1225 ERROR_CONNECTION_ABORTED: Final = 1236 - CONNECT_PIPE_INIT_DELAY: float - CONNECT_PIPE_MAX_DELAY: float + CONNECT_PIPE_INIT_DELAY: FloatInt + CONNECT_PIPE_MAX_DELAY: FloatInt class PipeServer: def __init__(self, address: str) -> None: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 96f9f637c733..18dad0542605 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import FileDescriptorLike, ReadableBuffer +from _typeshed import FileDescriptorLike, FloatInt, ReadableBuffer from socket import socket from typing import Any, TypeAlias, overload @@ -14,12 +14,12 @@ class ExitNow(Exception): ... def read(obj: Any) -> None: ... def write(obj: Any) -> None: ... def readwrite(obj: Any, flags: int) -> None: ... -def poll(timeout: float = 0.0, map: _MapType | None = None) -> None: ... -def poll2(timeout: float = 0.0, map: _MapType | None = None) -> None: ... +def poll(timeout: FloatInt = 0.0, map: _MapType | None = None) -> None: ... +def poll2(timeout: FloatInt = 0.0, map: _MapType | None = None) -> None: ... poll3 = poll2 -def loop(timeout: float = 30.0, use_poll: bool = False, map: _MapType | None = None, count: int | None = None) -> None: ... +def loop(timeout: FloatInt = 30.0, use_poll: bool = False, map: _MapType | None = None, count: int | None = None) -> None: ... # Not really subclass of socket.socket; it's only delegation. # It is not covariant to it. diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index a7d5e8adb7a5..89f82a58174b 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from typing import TypeAlias from typing_extensions import Buffer @@ -25,7 +26,7 @@ def lin2ulaw(fragment: Buffer, width: int, /) -> bytes: ... def max(fragment: Buffer, width: int, /) -> int: ... def maxpp(fragment: Buffer, width: int, /) -> int: ... def minmax(fragment: Buffer, width: int, /) -> tuple[int, int]: ... -def mul(fragment: Buffer, width: int, factor: float, /) -> bytes: ... +def mul(fragment: Buffer, width: int, factor: FloatInt, /) -> bytes: ... def ratecv( fragment: Buffer, width: int, @@ -39,6 +40,6 @@ def ratecv( ) -> tuple[bytes, _RatecvState]: ... def reverse(fragment: Buffer, width: int, /) -> bytes: ... def rms(fragment: Buffer, width: int, /) -> int: ... -def tomono(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes: ... -def tostereo(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes: ... +def tomono(fragment: Buffer, width: int, lfactor: FloatInt, rfactor: FloatInt, /) -> bytes: ... +def tostereo(fragment: Buffer, width: int, lfactor: FloatInt, rfactor: FloatInt, /) -> bytes: ... def ulaw2lin(fragment: Buffer, width: int, /) -> bytes: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 9fdbf0e4aa8d..730081a62e8f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -9,6 +9,7 @@ from _typeshed import ( ConvertibleToFloat, ConvertibleToInt, FileDescriptorOrPath, + FloatInt, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, @@ -371,28 +372,28 @@ class float: @property def imag(self) -> float: ... def conjugate(self) -> float: ... - def __add__(self, value: float, /) -> float: ... - def __sub__(self, value: float, /) -> float: ... - def __mul__(self, value: float, /) -> float: ... - def __floordiv__(self, value: float, /) -> float: ... - def __truediv__(self, value: float, /) -> float: ... - def __mod__(self, value: float, /) -> float: ... - def __divmod__(self, value: float, /) -> tuple[float, float]: ... + def __add__(self, value: FloatInt, /) -> float: ... + def __sub__(self, value: FloatInt, /) -> float: ... + def __mul__(self, value: FloatInt, /) -> float: ... + def __floordiv__(self, value: FloatInt, /) -> float: ... + def __truediv__(self, value: FloatInt, /) -> float: ... + def __mod__(self, value: FloatInt, /) -> float: ... + def __divmod__(self, value: FloatInt, /) -> tuple[float, float]: ... @overload def __pow__(self, value: int, mod: None = None, /) -> float: ... # positive __value -> float; negative __value -> complex # return type must be Any as `float | complex` causes too many false-positive errors @overload - def __pow__(self, value: float, mod: None = None, /) -> Any: ... + def __pow__(self, value: FloatInt, mod: None = None, /) -> Any: ... - def __radd__(self, value: float, /) -> float: ... - def __rsub__(self, value: float, /) -> float: ... - def __rmul__(self, value: float, /) -> float: ... - def __rfloordiv__(self, value: float, /) -> float: ... - def __rtruediv__(self, value: float, /) -> float: ... - def __rmod__(self, value: float, /) -> float: ... - def __rdivmod__(self, value: float, /) -> tuple[float, float]: ... + def __radd__(self, value: FloatInt, /) -> float: ... + def __rsub__(self, value: FloatInt, /) -> float: ... + def __rmul__(self, value: FloatInt, /) -> float: ... + def __rfloordiv__(self, value: FloatInt, /) -> float: ... + def __rtruediv__(self, value: FloatInt, /) -> float: ... + def __rmod__(self, value: FloatInt, /) -> float: ... + def __rdivmod__(self, value: FloatInt, /) -> tuple[float, float]: ... @overload def __rpow__(self, value: _PositiveInteger, mod: None = None, /) -> float: ... @@ -400,7 +401,7 @@ class float: def __rpow__(self, value: _NegativeInteger, mod: None = None, /) -> complex: ... # Returning `complex` for the general case gives too many false-positive errors. @overload - def __rpow__(self, value: float, mod: None = None, /) -> Any: ... + def __rpow__(self, value: FloatInt, mod: None = None, /) -> Any: ... def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... @@ -414,10 +415,10 @@ class float: def __eq__(self, value: object, /) -> bool: ... def __ne__(self, value: object, /) -> bool: ... - def __lt__(self, value: float, /) -> bool: ... - def __le__(self, value: float, /) -> bool: ... - def __gt__(self, value: float, /) -> bool: ... - def __ge__(self, value: float, /) -> bool: ... + def __lt__(self, value: FloatInt, /) -> bool: ... + def __le__(self, value: FloatInt, /) -> bool: ... + def __gt__(self, value: FloatInt, /) -> bool: ... + def __ge__(self, value: FloatInt, /) -> bool: ... def __neg__(self) -> float: ... def __pos__(self) -> float: ... def __int__(self) -> int: ... @@ -2171,21 +2172,21 @@ def pow(base: int, exp: _PositiveInteger, mod: None = None) -> int: ... def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ... # int base & positive-int exp -> int; int base & negative-int exp -> float -# return type must be Any as `int | float` causes too many false-positive errors +# return type must be Any as `float | int` causes too many false-positive errors @overload def pow(base: int, exp: int, mod: None = None) -> Any: ... @overload -def pow(base: _PositiveInteger, exp: float, mod: None = None) -> float: ... +def pow(base: _PositiveInteger, exp: FloatInt, mod: None = None) -> float: ... @overload -def pow(base: _NegativeInteger, exp: float, mod: None = None) -> complex: ... +def pow(base: _NegativeInteger, exp: FloatInt, mod: None = None) -> complex: ... @overload -def pow(base: float, exp: int, mod: None = None) -> float: ... +def pow(base: FloatInt, exp: int, mod: None = None) -> float: ... # float base & float exp could return float or complex # return type must be Any (same as complex base, complex exp), # as `float | complex` causes too many false-positive errors @overload -def pow(base: float, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> Any: ... +def pow(base: FloatInt, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> Any: ... @overload def pow(base: complex, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> complex: ... @overload diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index 4898b1c00232..ba0d4724d06f 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,12 +1,13 @@ +from _typeshed import FloatInt from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex, TypeAlias -e: Final[float] -pi: Final[float] -inf: Final[float] +e: Final[FloatInt] +pi: Final[FloatInt] +inf: Final[FloatInt] infj: Final[complex] -nan: Final[float] +nan: Final[FloatInt] nanj: Final[complex] -tau: Final[float] +tau: Final[FloatInt] _F: TypeAlias = SupportsFloat | SupportsIndex _C: TypeAlias = SupportsComplex | SupportsFloat | SupportsIndex | complex | float | int diff --git a/stdlib/colorsys.pyi b/stdlib/colorsys.pyi index d4edab12ecc7..f01a2db30500 100644 --- a/stdlib/colorsys.pyi +++ b/stdlib/colorsys.pyi @@ -1,15 +1,16 @@ +from _typeshed import FloatInt from typing import Final __all__ = ["rgb_to_yiq", "yiq_to_rgb", "rgb_to_hls", "hls_to_rgb", "rgb_to_hsv", "hsv_to_rgb"] -def rgb_to_yiq(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def yiq_to_rgb(y: float, i: float, q: float) -> tuple[float, float, float]: ... -def rgb_to_hls(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def hls_to_rgb(h: float, l: float, s: float) -> tuple[float, float, float]: ... -def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ... +def rgb_to_yiq(r: FloatInt, g: FloatInt, b: FloatInt) -> tuple[float, float, float]: ... +def yiq_to_rgb(y: FloatInt, i: FloatInt, q: FloatInt) -> tuple[float, float, float]: ... +def rgb_to_hls(r: FloatInt, g: FloatInt, b: FloatInt) -> tuple[float, float, float]: ... +def hls_to_rgb(h: FloatInt, l: FloatInt, s: FloatInt) -> tuple[float, float, float]: ... +def rgb_to_hsv(r: FloatInt, g: FloatInt, b: FloatInt) -> tuple[float, float, float]: ... +def hsv_to_rgb(h: FloatInt, s: FloatInt, v: FloatInt) -> tuple[float, float, float]: ... # undocumented -ONE_SIXTH: Final[float] -ONE_THIRD: Final[float] -TWO_THIRD: Final[float] +ONE_SIXTH: Final[FloatInt] +ONE_THIRD: Final[FloatInt] +TWO_THIRD: Final[FloatInt] diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 05680b5de461..bdab9e4f5838 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -1,6 +1,6 @@ import sys import threading -from _typeshed import Unused +from _typeshed import FloatInt, Unused from collections.abc import Callable, Iterable, Iterator from logging import Logger from types import GenericAlias, TracebackType @@ -44,10 +44,10 @@ class Future(Generic[_T]): def running(self) -> bool: ... def done(self) -> bool: ... def add_done_callback(self, fn: Callable[[Future[_T]], object]) -> None: ... - def result(self, timeout: float | None = None) -> _T: ... + def result(self, timeout: FloatInt | None = None) -> _T: ... def set_running_or_notify_cancel(self) -> bool: ... def set_result(self, result: _T) -> None: ... - def exception(self, timeout: float | None = None) -> BaseException | None: ... + def exception(self, timeout: FloatInt | None = None) -> BaseException | None: ... def set_exception(self, exception: BaseException | None) -> None: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @@ -58,13 +58,13 @@ class Executor: self, fn: Callable[..., _T], *iterables: Iterable[Any], - timeout: float | None = None, + timeout: FloatInt | None = None, chunksize: int = 1, buffersize: int | None = None, ) -> Iterator[_T]: ... else: def map( - self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = None, chunksize: int = 1 + self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: FloatInt | None = None, chunksize: int = 1 ) -> Iterator[_T]: ... def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None: ... @@ -82,16 +82,16 @@ class _AsCompletedFuture(Protocol[_T_co]): _state: str _waiters: list[_Waiter] # Not used by as_completed, but needed to propagate the generic type - def result(self, timeout: float | None = None) -> _T_co: ... + def result(self, timeout: FloatInt | None = None) -> _T_co: ... -def as_completed(fs: Iterable[_AsCompletedFuture[_T]], timeout: float | None = None) -> Iterator[Future[_T]]: ... +def as_completed(fs: Iterable[_AsCompletedFuture[_T]], timeout: FloatInt | None = None) -> Iterator[Future[_T]]: ... class DoneAndNotDoneFutures(NamedTuple, Generic[_T]): done: set[Future[_T]] not_done: set[Future[_T]] def wait( - fs: Iterable[Future[_T]], timeout: float | None = None, return_when: str = "ALL_COMPLETED" + fs: Iterable[Future[_T]], timeout: FloatInt | None = None, return_when: str = "ALL_COMPLETED" ) -> DoneAndNotDoneFutures[_T]: ... class _Waiter: diff --git a/stdlib/concurrent/interpreters/_queues.pyi b/stdlib/concurrent/interpreters/_queues.pyi index b4a4fd56dd45..7f682d75e9b2 100644 --- a/stdlib/concurrent/interpreters/_queues.pyi +++ b/stdlib/concurrent/interpreters/_queues.pyi @@ -1,5 +1,6 @@ import queue import sys +from _typeshed import FloatInt from typing import Final, SupportsIndex from typing_extensions import Self @@ -53,7 +54,7 @@ if sys.version_info >= (3, 14): # needed to satisfy pyright checks for Python < timeout: SupportsIndex | None = None, *, unbounditems: _AnyUnbound | None = None, - _delay: float = 0.01, + _delay: FloatInt = 0.01, ) -> None: ... else: def put( @@ -62,13 +63,13 @@ if sys.version_info >= (3, 14): # needed to satisfy pyright checks for Python < timeout: SupportsIndex | None = None, *, unbounditems: _AnyUnbound | None = None, - _delay: float = 0.01, + _delay: FloatInt = 0.01, ) -> None: ... def put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ... if sys.version_info >= (3, 14): - def get(self, block: bool = True, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ... + def get(self, block: bool = True, timeout: SupportsIndex | None = None, *, _delay: FloatInt = 0.01) -> object: ... else: - def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ... + def get(self, timeout: SupportsIndex | None = None, *, _delay: FloatInt = 0.01) -> object: ... def get_nowait(self) -> object: ... diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 5272e3850fe7..46f15698c9c2 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from abc import abstractmethod from time import struct_time from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only @@ -58,7 +59,7 @@ class date: resolution: ClassVar[timedelta] def __new__(cls, year: SupportsIndex, month: SupportsIndex, day: SupportsIndex) -> Self: ... @classmethod - def fromtimestamp(cls, timestamp: float, /) -> Self: ... + def fromtimestamp(cls, timestamp: FloatInt, /) -> Self: ... @classmethod def today(cls) -> Self: ... @classmethod @@ -221,13 +222,13 @@ class timedelta: resolution: ClassVar[timedelta] def __new__( cls, - days: float = 0, - seconds: float = 0, - microseconds: float = 0, - milliseconds: float = 0, - minutes: float = 0, - hours: float = 0, - weeks: float = 0, + days: FloatInt = 0, + seconds: FloatInt = 0, + microseconds: FloatInt = 0, + milliseconds: FloatInt = 0, + minutes: FloatInt = 0, + hours: FloatInt = 0, + weeks: FloatInt = 0, ) -> Self: ... @property def days(self) -> int: ... @@ -243,8 +244,8 @@ class timedelta: def __neg__(self) -> timedelta: ... def __pos__(self) -> timedelta: ... def __abs__(self) -> timedelta: ... - def __mul__(self, value: float, /) -> timedelta: ... - def __rmul__(self, value: float, /) -> timedelta: ... + def __mul__(self, value: FloatInt, /) -> timedelta: ... + def __rmul__(self, value: FloatInt, /) -> timedelta: ... @overload def __floordiv__(self, value: timedelta, /) -> int: ... @@ -254,7 +255,7 @@ class timedelta: @overload def __truediv__(self, value: timedelta, /) -> float: ... @overload - def __truediv__(self, value: float, /) -> timedelta: ... + def __truediv__(self, value: FloatInt, /) -> timedelta: ... def __mod__(self, value: timedelta, /) -> timedelta: ... def __divmod__(self, value: timedelta, /) -> tuple[int, timedelta]: ... @@ -334,23 +335,23 @@ class datetime(date, Generic[_TzInfoT]): if sys.version_info >= (3, 12): @overload # type: ignore[override] @classmethod - def fromtimestamp(cls, timestamp: float, tz: None = None) -> datetime[None]: ... + def fromtimestamp(cls, timestamp: FloatInt, tz: None = None) -> datetime[None]: ... @overload @classmethod - def fromtimestamp(cls, timestamp: float, tz: _TzInfo) -> datetime[_TzInfo]: ... + def fromtimestamp(cls, timestamp: FloatInt, tz: _TzInfo) -> datetime[_TzInfo]: ... @overload @classmethod - def fromtimestamp(cls, timestamp: float, tz: _TzInfo | None) -> datetime[_TzInfo] | datetime[None]: ... + def fromtimestamp(cls, timestamp: FloatInt, tz: _TzInfo | None) -> datetime[_TzInfo] | datetime[None]: ... else: @overload # type: ignore[override] @classmethod - def fromtimestamp(cls, timestamp: float, /, tz: None = None) -> datetime[None]: ... + def fromtimestamp(cls, timestamp: FloatInt, /, tz: None = None) -> datetime[None]: ... @overload @classmethod - def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo) -> datetime[_TzInfo]: ... + def fromtimestamp(cls, timestamp: FloatInt, /, tz: _TzInfo) -> datetime[_TzInfo]: ... @overload @classmethod - def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None) -> datetime[_TzInfo] | datetime[None]: ... + def fromtimestamp(cls, timestamp: FloatInt, /, tz: _TzInfo | None) -> datetime[_TzInfo] | datetime[None]: ... # fromisoformat returns Self, but we can't specialize "Self" if sys.version_info >= (3, 15): @@ -362,7 +363,7 @@ class datetime(date, Generic[_TzInfoT]): @classmethod @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC)") - def utcfromtimestamp(cls, t: float, /) -> datetime[None]: ... + def utcfromtimestamp(cls, t: FloatInt, /) -> datetime[None]: ... @overload @classmethod diff --git a/stdlib/dbm/sqlite3.pyi b/stdlib/dbm/sqlite3.pyi index e7034cfde50d..c4e677cefdf3 100644 --- a/stdlib/dbm/sqlite3.pyi +++ b/stdlib/dbm/sqlite3.pyi @@ -13,7 +13,7 @@ ITER_KEYS: Final[LiteralString] if sys.version_info >= (3, 15): REORGANIZE: Final[LiteralString] -_SqliteData: TypeAlias = str | ReadableBuffer | int | float +_SqliteData: TypeAlias = str | ReadableBuffer | float | int class error(OSError): ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index f116603cf0f2..e52432e26211 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -24,6 +24,7 @@ from _decimal import ( localcontext as localcontext, setcontext as setcontext, ) +from _typeshed import FloatInt from collections.abc import Container, Sequence from types import TracebackType from typing import Any, ClassVar, Literal, NamedTuple, TypeAlias, final, overload, type_check_only @@ -35,8 +36,8 @@ if sys.version_info >= (3, 15): from _decimal import SPEC_VERSION as SPEC_VERSION _Decimal: TypeAlias = Decimal | int -_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int] -_ComparableNum: TypeAlias = Decimal | float | numbers.Rational +_DecimalNew: TypeAlias = Decimal | FloatInt | str | tuple[int, Sequence[int], int] +_ComparableNum: TypeAlias = Decimal | FloatInt | numbers.Rational _TrapType: TypeAlias = type[DecimalException] # At runtime, these classes are implemented in C as part of "_decimal". @@ -75,10 +76,10 @@ class Decimal: def __new__(cls, value: _DecimalNew = "0", context: Context | None = None) -> Self: ... if sys.version_info >= (3, 14): @classmethod - def from_number(cls, number: Decimal | float, /) -> Self: ... + def from_number(cls, number: Decimal | FloatInt, /) -> Self: ... @classmethod - def from_float(cls, f: float, /) -> Self: ... + def from_float(cls, f: FloatInt, /) -> Self: ... def __bool__(self) -> bool: ... def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ... def __hash__(self) -> int: ... @@ -214,7 +215,7 @@ class Context: def Etiny(self) -> int: ... def Etop(self) -> int: ... def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal: ... - def create_decimal_from_float(self, f: float, /) -> Decimal: ... + def create_decimal_from_float(self, f: FloatInt, /) -> Decimal: ... def abs(self, x: _Decimal, /) -> Decimal: ... def add(self, x: _Decimal, y: _Decimal, /) -> Decimal: ... def canonical(self, x: Decimal, /) -> Decimal: ... diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index a3bda7f9b2d0..041856fb41d8 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -1,5 +1,6 @@ import re import sys +from _typeshed import FloatInt from collections.abc import Callable, Iterable, Iterator, Sequence from types import GenericAlias from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload @@ -53,10 +54,10 @@ class SequenceMatcher(Generic[_T]): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @overload -def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ... +def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: FloatInt = 0.6) -> list[AnyStr]: ... @overload def get_close_matches( - word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = 3, cutoff: float = 0.6 + word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = 3, cutoff: FloatInt = 0.6 ) -> list[Sequence[_T]]: ... class Differ: diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index db42aff7d1f3..c8f9badac56e 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,6 +1,6 @@ import datetime import sys -from _typeshed import Unused +from _typeshed import FloatInt, Unused from collections.abc import Iterable from email import _ParamType from email.charset import Charset @@ -49,7 +49,7 @@ def parsedate_tz(data: str) -> _PDTZ | None: ... def parsedate_to_datetime(data: str) -> datetime.datetime: ... def mktime_tz(data: _PDTZ) -> int: ... -def formatdate(timeval: float | None = None, localtime: bool = False, usegmt: bool = False) -> str: ... +def formatdate(timeval: FloatInt | None = None, localtime: bool = False, usegmt: bool = False) -> str: ... def format_datetime(dt: datetime.datetime, usegmt: bool = False) -> str: ... if sys.version_info >= (3, 14): diff --git a/stdlib/faulthandler.pyi b/stdlib/faulthandler.pyi index 6999933c43b9..cc2b3e82673e 100644 --- a/stdlib/faulthandler.pyi +++ b/stdlib/faulthandler.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import FileDescriptorLike +from _typeshed import FileDescriptorLike, FloatInt def cancel_dump_traceback_later() -> None: ... def disable() -> None: ... @@ -17,7 +17,7 @@ if sys.version_info >= (3, 14): if sys.version_info >= (3, 15): def dump_traceback_later( - timeout: float, + timeout: FloatInt, repeat: bool = False, file: FileDescriptorLike = sys.stderr, exit: bool = False, @@ -27,7 +27,7 @@ if sys.version_info >= (3, 15): else: def dump_traceback_later( - timeout: float, repeat: bool = False, file: FileDescriptorLike = sys.stderr, exit: bool = False + timeout: FloatInt, repeat: bool = False, file: FileDescriptorLike = sys.stderr, exit: bool = False ) -> None: ... if sys.version_info >= (3, 15): diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 42947f2e2266..bf07da84775a 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -1,11 +1,12 @@ import sys +from _typeshed import FloatInt from collections.abc import Callable from decimal import Decimal from numbers import Rational, Real from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only from typing_extensions import Self -_ComparableNum: TypeAlias = int | float | Decimal | Real +_ComparableNum: TypeAlias = float | int | Decimal | Real __all__ = ["Fraction"] @@ -19,13 +20,13 @@ class Fraction(Rational): @overload def __new__(cls, numerator: int | Rational = 0, denominator: int | Rational | None = None) -> Self: ... @overload - def __new__(cls, numerator: float | Decimal | str) -> Self: ... + def __new__(cls, numerator: FloatInt | Decimal | str) -> Self: ... if sys.version_info >= (3, 14): @overload def __new__(cls, numerator: _ConvertibleToIntegerRatio) -> Self: ... @classmethod - def from_float(cls, f: float) -> Self: ... + def from_float(cls, f: FloatInt) -> Self: ... @classmethod def from_decimal(cls, dec: Decimal) -> Self: ... def limit_denominator(self, max_denominator: int = 1000000) -> Fraction: ... @@ -41,112 +42,112 @@ class Fraction(Rational): @overload def __add__(a, b: int | Fraction) -> Fraction: ... @overload - def __add__(a, b: float) -> float: ... + def __add__(a, b: FloatInt) -> float: ... @overload def __add__(a, b: complex) -> complex: ... @overload def __radd__(b, a: int | Fraction) -> Fraction: ... @overload - def __radd__(b, a: float) -> float: ... + def __radd__(b, a: FloatInt) -> float: ... @overload def __radd__(b, a: complex) -> complex: ... @overload def __sub__(a, b: int | Fraction) -> Fraction: ... @overload - def __sub__(a, b: float) -> float: ... + def __sub__(a, b: FloatInt) -> float: ... @overload def __sub__(a, b: complex) -> complex: ... @overload def __rsub__(b, a: int | Fraction) -> Fraction: ... @overload - def __rsub__(b, a: float) -> float: ... + def __rsub__(b, a: FloatInt) -> float: ... @overload def __rsub__(b, a: complex) -> complex: ... @overload def __mul__(a, b: int | Fraction) -> Fraction: ... @overload - def __mul__(a, b: float) -> float: ... + def __mul__(a, b: FloatInt) -> float: ... @overload def __mul__(a, b: complex) -> complex: ... @overload def __rmul__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmul__(b, a: float) -> float: ... + def __rmul__(b, a: FloatInt) -> float: ... @overload def __rmul__(b, a: complex) -> complex: ... @overload def __truediv__(a, b: int | Fraction) -> Fraction: ... @overload - def __truediv__(a, b: float) -> float: ... + def __truediv__(a, b: FloatInt) -> float: ... @overload def __truediv__(a, b: complex) -> complex: ... @overload def __rtruediv__(b, a: int | Fraction) -> Fraction: ... @overload - def __rtruediv__(b, a: float) -> float: ... + def __rtruediv__(b, a: FloatInt) -> float: ... @overload def __rtruediv__(b, a: complex) -> complex: ... @overload def __floordiv__(a, b: int | Fraction) -> int: ... @overload - def __floordiv__(a, b: float) -> float: ... + def __floordiv__(a, b: FloatInt) -> float: ... @overload def __rfloordiv__(b, a: int | Fraction) -> int: ... @overload - def __rfloordiv__(b, a: float) -> float: ... + def __rfloordiv__(b, a: FloatInt) -> float: ... @overload def __mod__(a, b: int | Fraction) -> Fraction: ... @overload - def __mod__(a, b: float) -> float: ... + def __mod__(a, b: FloatInt) -> float: ... @overload def __rmod__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmod__(b, a: float) -> float: ... + def __rmod__(b, a: FloatInt) -> float: ... @overload def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __divmod__(a, b: float) -> tuple[float, Fraction]: ... + def __divmod__(a, b: FloatInt) -> tuple[float, Fraction]: ... @overload def __rdivmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __rdivmod__(a, b: float) -> tuple[float, Fraction]: ... + def __rdivmod__(a, b: FloatInt) -> tuple[float, Fraction]: ... if sys.version_info >= (3, 14): @overload def __pow__(a, b: int, modulo: None = None) -> Fraction: ... @overload - def __pow__(a, b: float | Fraction, modulo: None = None) -> float: ... + def __pow__(a, b: FloatInt | Fraction, modulo: None = None) -> float: ... @overload def __pow__(a, b: complex, modulo: None = None) -> complex: ... else: @overload def __pow__(a, b: int) -> Fraction: ... @overload - def __pow__(a, b: float | Fraction) -> float: ... + def __pow__(a, b: FloatInt | Fraction) -> float: ... @overload def __pow__(a, b: complex) -> complex: ... if sys.version_info >= (3, 14): @overload - def __rpow__(b, a: float | Fraction, modulo: None = None) -> float: ... + def __rpow__(b, a: FloatInt | Fraction, modulo: None = None) -> float: ... @overload def __rpow__(b, a: complex, modulo: None = None) -> complex: ... else: @overload - def __rpow__(b, a: float | Fraction) -> float: ... + def __rpow__(b, a: FloatInt | Fraction) -> float: ... @overload def __rpow__(b, a: complex) -> complex: ... @@ -182,4 +183,4 @@ class Fraction(Rational): def conjugate(self) -> Fraction: ... if sys.version_info >= (3, 14): @classmethod - def from_number(cls, number: float | Rational | _ConvertibleToIntegerRatio) -> Self: ... + def from_number(cls, number: FloatInt | Rational | _ConvertibleToIntegerRatio) -> Self: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index 1b7222fc94f7..c5c6a686fe2f 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import StrOrBytesPath, SupportsRead, SupportsReadline +from _typeshed import FloatInt, StrOrBytesPath, SupportsRead, SupportsReadline from collections.abc import Callable, Iterable, Iterator from socket import socket from ssl import SSLContext @@ -31,7 +31,7 @@ class FTP: sock: socket | None welcome: str | None passiveserver: int - timeout: float | None + timeout: FloatInt | None af: int lastresp: str file: TextIO | None @@ -47,13 +47,13 @@ class FTP: user: str = "", passwd: str = "", acct: str = "", - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, *, encoding: str = "utf-8", ) -> None: ... def connect( - self, host: str = "", port: int = 0, timeout: float = -999, source_address: tuple[str, int] | None = None + self, host: str = "", port: int = 0, timeout: FloatInt = -999, source_address: tuple[str, int] | None = None ) -> str: ... def getwelcome(self) -> str: ... def set_debuglevel(self, level: int) -> None: ... @@ -115,7 +115,7 @@ class FTP_TLS(FTP): acct: str = "", *, context: SSLContext | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, encoding: str = "utf-8", ) -> None: ... @@ -130,7 +130,7 @@ class FTP_TLS(FTP): keyfile: None = None, certfile: None = None, context: SSLContext | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, *, encoding: str = "utf-8", @@ -149,7 +149,7 @@ class FTP_TLS(FTP): keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, context: None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, *, encoding: str = "utf-8", diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index 4322e6c84c90..bd5bd5310c1c 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -1,6 +1,6 @@ import sys import zlib -from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer +from _typeshed import FloatInt, ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO, TextIOWrapper from typing import Final, Literal, Protocol, TypeAlias, overload, type_check_only from typing_extensions import deprecated @@ -104,7 +104,7 @@ class GzipFile(BaseStream): mode: _ReadBinaryMode, compresslevel: int = 9, fileobj: _ReadableFileobj | None = None, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... @overload def __init__( @@ -113,7 +113,7 @@ class GzipFile(BaseStream): mode: _ReadBinaryMode, compresslevel: int = 9, fileobj: _ReadableFileobj | None = None, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... @overload def __init__( @@ -122,7 +122,7 @@ class GzipFile(BaseStream): mode: _WriteBinaryMode, compresslevel: int = 9, fileobj: _WritableFileobj | None = None, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... @overload def __init__( @@ -131,7 +131,7 @@ class GzipFile(BaseStream): mode: _WriteBinaryMode, compresslevel: int = 9, fileobj: _WritableFileobj | None = None, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... @overload def __init__( @@ -140,7 +140,7 @@ class GzipFile(BaseStream): mode: str | None = None, compresslevel: int = 9, fileobj: _ReadableFileobj | _WritableFileobj | None = None, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... if sys.version_info < (3, 12): @@ -170,12 +170,12 @@ class _GzipReader(DecompressReader): def __init__(self, fp: _ReadableFileobj) -> None: ... if sys.version_info >= (3, 15): - def compress(data: SizedBuffer, compresslevel: int = 6, *, mtime: float = 0) -> bytes: ... + def compress(data: SizedBuffer, compresslevel: int = 6, *, mtime: FloatInt = 0) -> bytes: ... elif sys.version_info >= (3, 14): - def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: float = 0) -> bytes: ... + def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: FloatInt = 0) -> bytes: ... else: - def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: float | None = None) -> bytes: ... + def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: FloatInt | None = None) -> bytes: ... def decompress(data: ReadableBuffer) -> bytes: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index d22335b56c54..ade9101a30b3 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -3,7 +3,7 @@ import io import ssl import sys import types -from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsRead, SupportsReadline, WriteableBuffer +from _typeshed import FloatInt, MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsRead, SupportsReadline, WriteableBuffer from collections.abc import Callable, Iterable, Iterator, Mapping from email._policybase import _MessageT from socket import socket @@ -176,7 +176,7 @@ class HTTPConnection: debuglevel: int default_port: int # undocumented response_class: type[HTTPResponse] # undocumented - timeout: float | None + timeout: FloatInt | None host: str port: int sock: socket | MaybeNone # can be `None` if `.connect()` was not called @@ -185,7 +185,7 @@ class HTTPConnection: self, host: str, port: int | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, blocksize: int = 8192, *, @@ -196,7 +196,7 @@ class HTTPConnection: self, host: str, port: int | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, blocksize: int = 8192, ) -> None: ... @@ -232,7 +232,7 @@ class HTTPSConnection(HTTPConnection): host: str, port: int | None = None, *, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, context: ssl.SSLContext | None = None, blocksize: int = 8192, @@ -244,7 +244,7 @@ class HTTPSConnection(HTTPConnection): host: str, port: int | None = None, *, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, context: ssl.SSLContext | None = None, blocksize: int = 8192, @@ -257,7 +257,7 @@ class HTTPSConnection(HTTPConnection): port: int | None = None, key_file: None = None, cert_file: None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, *, context: ssl.SSLContext | None = None, @@ -275,7 +275,7 @@ class HTTPSConnection(HTTPConnection): port: int | None = None, key_file: StrOrBytesPath | None = None, cert_file: StrOrBytesPath | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: tuple[str, int] | None = None, *, context: ssl.SSLContext | None = None, diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 1bd2fbcbd75d..e7187fdc4668 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,4 +1,4 @@ -from _typeshed import StrPath +from _typeshed import FloatInt, StrPath from collections.abc import Iterator, Sequence from http.client import HTTPResponse from re import Pattern @@ -140,7 +140,7 @@ class Cookie: path: str, path_specified: bool, secure: bool, - expires: float | str | None, + expires: FloatInt | str | None, discard: bool, comment: str | None, comment_url: str | None, diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index e739c8a55968..49216605f231 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -4,7 +4,7 @@ import io import socketserver import sys from _ssl import _PasswordType -from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Mapping, Sequence from ssl import Purpose, SSLContext from typing import Any, AnyStr, BinaryIO, ClassVar, Protocol, type_check_only @@ -87,7 +87,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): def log_error(self, format: str, *args: Any) -> None: ... def log_message(self, format: str, *args: Any) -> None: ... def version_string(self) -> str: ... - def date_time_string(self, timestamp: float | None = None) -> str: ... + def date_time_string(self, timestamp: FloatInt | None = None) -> str: ... def log_date_time_string(self) -> str: ... def address_string(self) -> str: ... def parse_request(self) -> bool: ... # undocumented diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index bb58d29099e5..81202145212b 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,7 +1,7 @@ import subprocess import sys import time -from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, Unused +from _typeshed import FloatInt, ReadableBuffer, SizedBuffer, StrOrBytesPath, Unused from builtins import list as _list # conflicts with a method named "list" from collections.abc import Callable, Generator from datetime import datetime @@ -41,8 +41,8 @@ class IMAP4: welcome: bytes capabilities: tuple[str, ...] PROTOCOL_VERSION: str - def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... - def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... + def __init__(self, host: str = "", port: int = 143, timeout: FloatInt | None = None) -> None: ... + def open(self, host: str = "", port: int = 143, timeout: FloatInt | None = None) -> None: ... if sys.version_info >= (3, 14): @property @deprecated("IMAP4.file is unsupported, can cause errors, and may be removed.") @@ -82,7 +82,7 @@ class IMAP4: def getquota(self, root: str) -> _CommandResults: ... def getquotaroot(self, mailbox: str) -> _CommandResults: ... if sys.version_info >= (3, 14): - def idle(self, duration: float | None = None) -> Idler: ... + def idle(self, duration: FloatInt | None = None) -> Idler: ... if sys.version_info >= (3, 13): # Default was fixed in Python 3.13.15, 3.14.7 @@ -131,17 +131,17 @@ class IMAP4: if sys.version_info >= (3, 14): class Idler: - def __init__(self, imap: IMAP4, duration: float | None = None) -> None: ... + def __init__(self, imap: IMAP4, duration: FloatInt | None = None) -> None: ... def __enter__(self) -> Self: ... def __exit__(self, exc_type: object, exc_val: Unused, exc_tb: Unused) -> Literal[False]: ... def __iter__(self) -> Self: ... def __next__(self) -> tuple[str, float | None]: ... - def burst(self, interval: float = 0.1) -> Generator[tuple[str, float | None]]: ... + def burst(self, interval: FloatInt = 0.1) -> Generator[tuple[str, float | None]]: ... class IMAP4_SSL(IMAP4): if sys.version_info >= (3, 12): def __init__( - self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None + self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: FloatInt | None = None ) -> None: ... else: @overload @@ -152,7 +152,7 @@ class IMAP4_SSL(IMAP4): keyfile: None = None, certfile: None = None, ssl_context: SSLContext | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, ) -> None: ... @overload @deprecated( @@ -166,7 +166,7 @@ class IMAP4_SSL(IMAP4): keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, ssl_context: None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, ) -> None: ... keyfile: StrOrBytesPath | None @@ -179,7 +179,7 @@ class IMAP4_SSL(IMAP4): else: file: IO[Any] - def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ... + def open(self, host: str = "", port: int | None = 993, timeout: FloatInt | None = None) -> None: ... def ssl(self) -> SSLSocket: ... class IMAP4_stream(IMAP4): @@ -194,7 +194,7 @@ class IMAP4_stream(IMAP4): process: subprocess.Popen[bytes] writefile: IO[Any] readfile: IO[Any] - def open(self, host: str | None = None, port: int | None = None, timeout: float | None = None) -> None: ... + def open(self, host: str | None = None, port: int | None = None, timeout: FloatInt | None = None) -> None: ... class _Authenticator: mech: Callable[[bytes], bytes | bytearray | memoryview | str | None] @@ -207,6 +207,6 @@ def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time | None: ... def Int2AP(num: SupportsAbs[SupportsInt]) -> bytes: ... def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... -_TimeLike: TypeAlias = float | time.struct_time | time._TimeTuple | datetime | str +_TimeLike: TypeAlias = FloatInt | time.struct_time | time._TimeTuple | datetime | str def Time2Internaldate(date_time: _TimeLike) -> str: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index d26a4e1da21e..9aeb9972bd03 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -7,7 +7,7 @@ from typing_extensions import Self, disjoint_base _T = TypeVar("_T") _S = TypeVar("_S") -_N = TypeVar("_N", int, float, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex) +_N = TypeVar("_N", float, int, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex) _T_co = TypeVar("_T_co", covariant=True) _S_co = TypeVar("_S_co", covariant=True) _T1 = TypeVar("_T1") diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index 83b78666d4a7..21532584e36b 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from collections.abc import Callable, Iterator from re import Pattern from typing import Any, Final @@ -6,7 +7,7 @@ ESCAPE: Final[Pattern[str]] # undocumented ESCAPE_ASCII: Final[Pattern[str]] # undocumented HAS_UTF8: Final[Pattern[bytes]] # undocumented ESCAPE_DCT: Final[dict[str, str]] # undocumented -INFINITY: Final[float] # undocumented +INFINITY: Final[FloatInt] # undocumented def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index f527e7084ced..e8bb3d8d467a 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,10 +1,11 @@ +from _typeshed import FloatInt from collections.abc import Callable from typing import Any, TypeAlias __all__ = ["getline", "clearcache", "checkcache", "lazycache"] _ModuleGlobals: TypeAlias = dict[str, Any] -_ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str] +_ModuleMetadata: TypeAlias = tuple[int, FloatInt | None, list[str], str] _SourceLoader: TypeAlias = tuple[Callable[[], str | None]] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index d234a08d779c..dc9f35f099e5 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -11,6 +11,7 @@ from _locale import ( strcoll as strcoll, strxfrm as strxfrm, ) +from _typeshed import FloatInt # This module defines a function "str()", which is why "str" can't be used # as a type annotation or type alias. @@ -144,16 +145,16 @@ if sys.version_info < (3, 13): if sys.version_info < (3, 12): @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `locale.format_string()` instead.") def format( - percent: _str, value: float | Decimal, grouping: bool = False, monetary: bool = False, *additional: Any + percent: _str, value: FloatInt | Decimal, grouping: bool = False, monetary: bool = False, *additional: Any ) -> _str: ... def format_string(f: _str, val: Any, grouping: bool = False, monetary: bool = False) -> _str: ... -def currency(val: float | Decimal, symbol: bool = True, grouping: bool = False, international: bool = False) -> _str: ... +def currency(val: FloatInt | Decimal, symbol: bool = True, grouping: bool = False, international: bool = False) -> _str: ... def delocalize(string: _str) -> _str: ... def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... -def str(val: float) -> _str: ... +def str(val: FloatInt) -> _str: ... locale_alias: dict[_str, _str] # undocumented locale_encoding_alias: dict[_str, _str] # undocumented diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index d7799e3c948f..2127f45a002b 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -1,6 +1,6 @@ import sys import threading -from _typeshed import StrPath, SupportsWrite +from _typeshed import FloatInt, StrPath, SupportsWrite from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from io import TextIOWrapper from re import Pattern @@ -267,7 +267,7 @@ if sys.version_info >= (3, 12): def getHandlerNames() -> frozenset[str]: ... class Formatter: - converter: Callable[[float | None], struct_time] + converter: Callable[[FloatInt | None], struct_time] _fmt: str | None # undocumented datefmt: str | None # undocumented _style: PercentStyle # undocumented @@ -312,7 +312,7 @@ class LogRecord: # see https://github.com/python/cpython/issues/88639 args: _ArgsType | None asctime: str - created: float + created: FloatInt # Prior to Python 3.16, Logger._log() only normalizes truthy exc_info # values so exc_info=False ends up on the record unchanged. exc_info: _SysExcInfoType | Literal[False] | None @@ -323,7 +323,7 @@ class LogRecord: levelno: int lineno: int module: str - msecs: float + msecs: FloatInt # Only created when logging.Formatter.format is called. See #6132. message: str msg: str | Any # The runtime accepts any object, but will be a str in 99% of cases @@ -331,7 +331,7 @@ class LogRecord: pathname: str process: int | None processName: str | None - relativeCreated: float + relativeCreated: FloatInt stack_info: str | None thread: int | None threadName: str | None diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 535f1c685183..0d0da994b243 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -2,7 +2,7 @@ import datetime import http.client import ssl import sys -from _typeshed import ReadableBuffer, StrPath +from _typeshed import FloatInt, ReadableBuffer, StrPath from collections.abc import Callable from logging import FileHandler, Handler, LogRecord from re import Pattern @@ -88,12 +88,12 @@ class SocketHandler(Handler): address: tuple[str, int] | str # undocumented sock: socket | None # undocumented closeOnError: bool # undocumented - retryTime: float | None # undocumented - retryStart: float # undocumented - retryFactor: float # undocumented - retryMax: float # undocumented + retryTime: FloatInt | None # undocumented + retryStart: FloatInt # undocumented + retryFactor: FloatInt # undocumented + retryMax: FloatInt # undocumented def __init__(self, host: str, port: int | None) -> None: ... - def makeSocket(self, timeout: float = 1) -> socket: ... # timeout is undocumented + def makeSocket(self, timeout: FloatInt = 1) -> socket: ... # timeout is undocumented def makePickle(self, record: LogRecord) -> bytes: ... def send(self, s: ReadableBuffer) -> None: ... def createSocket(self) -> None: ... @@ -145,13 +145,13 @@ class SysLogHandler(Handler): facility_names: ClassVar[dict[str, int]] # undocumented priority_map: ClassVar[dict[str, str]] # undocumented if sys.version_info >= (3, 14): - timeout: float | None + timeout: FloatInt | None def __init__( self, address: tuple[str, int] | str = ("localhost", 514), facility: str | int = 1, socktype: SocketKind | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, ) -> None: ... else: def __init__( @@ -180,7 +180,7 @@ class SMTPHandler(Handler): toaddrs: list[str] # undocumented subject: str # undocumented secure: tuple[()] | tuple[str] | tuple[str, str] | None # undocumented - timeout: float # undocumented + timeout: FloatInt # undocumented def __init__( self, mailhost: str | tuple[str, int], @@ -189,7 +189,7 @@ class SMTPHandler(Handler): subject: str, credentials: tuple[str, str] | None = None, secure: tuple[()] | tuple[str] | tuple[str, str] | None = None, - timeout: float = 5.0, + timeout: FloatInt = 5.0, ) -> None: ... def getSubject(self, record: LogRecord) -> str: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 7f3024094b43..bbfbe66b08a7 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -1,7 +1,7 @@ import email.message import io import sys -from _typeshed import StrPath, SupportsItems, SupportsNoArgReadline, SupportsRead, SupportsWrite, Unused +from _typeshed import FloatInt, StrPath, SupportsItems, SupportsNoArgReadline, SupportsRead, SupportsWrite, Unused from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from types import GenericAlias, TracebackType @@ -244,7 +244,7 @@ class MaildirMessage(Message): def add_flag(self, flag: str) -> None: ... def remove_flag(self, flag: str) -> None: ... def get_date(self) -> int: ... - def set_date(self, date: float) -> None: ... + def set_date(self, date: FloatInt) -> None: ... def get_info(self) -> str: ... def set_info(self, info: str) -> None: ... diff --git a/stdlib/marshal.pyi b/stdlib/marshal.pyi index 04cdf05b1934..f7410ea662ed 100644 --- a/stdlib/marshal.pyi +++ b/stdlib/marshal.pyi @@ -20,10 +20,7 @@ _Marshallable: TypeAlias = ( | types.CodeType | ReadableBuffer # handled in w_object() in marshal.c - | type[StopIteration] - | types.EllipsisType - | bool - | None + | type[StopIteration] | types.EllipsisType | bool | None ) if sys.version_info >= (3, 15): diff --git a/stdlib/math/__init__.pyi b/stdlib/math/__init__.pyi index b11324c4ae9a..972af80cbd29 100644 --- a/stdlib/math/__init__.pyi +++ b/stdlib/math/__init__.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import SupportsMul, SupportsRMul +from _typeshed import FloatInt, SupportsMul, SupportsRMul from collections.abc import Iterable from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only @@ -8,11 +8,11 @@ _T_co = TypeVar("_T_co", covariant=True) _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex -e: Final[float] -pi: Final[float] -inf: Final[float] -nan: Final[float] -tau: Final[float] +e: Final[FloatInt] +pi: Final[FloatInt] +inf: Final[FloatInt] +nan: Final[FloatInt] +tau: Final[FloatInt] def acos(x: _SupportsFloatOrIndex, /) -> float: ... def acosh(x: _SupportsFloatOrIndex, /) -> float: ... @@ -139,7 +139,7 @@ if sys.version_info >= (3, 15): def sinh(x: _SupportsFloatOrIndex, /) -> float: ... if sys.version_info >= (3, 12): - def sumprod(p: Iterable[float], q: Iterable[float], /) -> float: ... + def sumprod(p: Iterable[FloatInt], q: Iterable[FloatInt], /) -> float: ... def sqrt(x: _SupportsFloatOrIndex, /) -> float: ... def tan(x: _SupportsFloatOrIndex, /) -> float: ... diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index c63e6920fc46..eb1a282fa796 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,6 +1,6 @@ import socket import sys -from _typeshed import Incomplete, ReadableBuffer +from _typeshed import FloatInt, Incomplete, ReadableBuffer from collections.abc import Iterable from types import TracebackType from typing import Any, Generic, SupportsIndex, TypeAlias, TypeVar @@ -31,7 +31,7 @@ class _ConnectionBase(Generic[_SendT_contra, _RecvT_co]): def recv_bytes(self, maxlength: int | None = None) -> bytes: ... def recv_bytes_into(self, buf: Any, offset: int = 0) -> int: ... def recv(self) -> _RecvT_co: ... - def poll(self, timeout: float | None = 0.0) -> bool: ... + def poll(self, timeout: FloatInt | None = 0.0) -> bool: ... def __enter__(self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None @@ -73,7 +73,7 @@ else: def answer_challenge(connection: _ConnectionBase[Any, Any], authkey: bytes) -> None: ... def wait( - object_list: Iterable[_ConnectionBase[_SendT_contra, _RecvT_co] | socket.socket | int], timeout: float | None = None + object_list: Iterable[_ConnectionBase[_SendT_contra, _RecvT_co] | socket.socket | int], timeout: FloatInt | None = None ) -> list[_ConnectionBase[_SendT_contra, _RecvT_co] | socket.socket | int]: ... if sys.platform != "win32": diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 925f364f1826..13de83311e59 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -1,6 +1,7 @@ import ctypes import sys from _ctypes import _CData +from _typeshed import FloatInt from collections.abc import Callable, Iterable, Sequence from ctypes import _SimpleCData, c_char from logging import Logger, _Level as _LoggingLevel @@ -56,7 +57,7 @@ class BaseContext: def Pipe(self, duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ... def Barrier( - self, parties: int, action: Callable[..., object] | None = None, timeout: float | None = None + self, parties: int, action: Callable[..., object] | None = None, timeout: FloatInt | None = None ) -> synchronize.Barrier: ... def BoundedSemaphore(self, value: int = 1) -> synchronize.BoundedSemaphore: ... def Condition(self, lock: _LockLike | None = None) -> synchronize.Condition: ... diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index d7e982129466..a06186ed53ed 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from multiprocessing.connection import _Address from queue import Queue from types import TracebackType @@ -21,7 +22,7 @@ class Connection: ) -> None: ... def __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... - def poll(self, timeout: float = 0.0) -> bool: ... + def poll(self, timeout: FloatInt = 0.0) -> bool: ... class Listener: _backlog_queue: Queue[Any] | None diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 0727f60f1080..2b4cd138bbde 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -2,7 +2,7 @@ import builtins import queue import sys import threading -from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT +from _typeshed import FloatInt, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT from collections.abc import ( Callable, Iterable, @@ -289,7 +289,7 @@ class BaseManager: serializer: str = "pickle", ctx: BaseContext | None = None, *, - shutdown_timeout: float = 1.0, + shutdown_timeout: FloatInt = 1.0, ) -> None: ... else: def __init__( @@ -304,7 +304,7 @@ class BaseManager: def connect(self) -> None: ... def start(self, initializer: Callable[..., object] | None = None, initargs: Iterable[Any] = ()) -> None: ... shutdown: _Finalize # only available after start() was called - def join(self, timeout: float | None = None) -> None: ... # undocumented + def join(self, timeout: FloatInt | None = None) -> None: ... # undocumented @property def address(self) -> _Address | None: ... @classmethod @@ -324,7 +324,7 @@ class BaseManager: class SyncManager(BaseManager): def Barrier( - self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None + self, parties: int, action: Callable[[], None] | None = None, timeout: FloatInt | None = None ) -> threading.Barrier: ... def BoundedSemaphore(self, value: int = 1) -> threading.BoundedSemaphore: ... def Condition(self, lock: threading.Lock | threading._RLock | None = None) -> threading.Condition: ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 5642e50d0e76..48ca13df56ac 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from collections.abc import Callable, Iterable, Mapping from multiprocessing.context import DefaultContext, Process as _Process from types import GenericAlias, TracebackType @@ -13,8 +14,8 @@ class ApplyResult(Generic[_T]): def __init__( self, pool: Pool, callback: Callable[[_T], object] | None, error_callback: Callable[[BaseException], object] | None ) -> None: ... - def get(self, timeout: float | None = None) -> _T: ... - def wait(self, timeout: float | None = None) -> None: ... + def get(self, timeout: FloatInt | None = None) -> _T: ... + def wait(self, timeout: FloatInt | None = None) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @@ -35,8 +36,8 @@ class MapResult(ApplyResult[list[_T]]): class IMapIterator(Generic[_T]): def __init__(self, pool: Pool) -> None: ... def __iter__(self) -> Self: ... - def next(self, timeout: float | None = None) -> _T: ... - def __next__(self, timeout: float | None = None) -> _T: ... + def next(self, timeout: FloatInt | None = None) -> _T: ... + def __next__(self, timeout: FloatInt | None = None) -> _T: ... class IMapUnorderedIterator(IMapIterator[_T]): ... diff --git a/stdlib/multiprocessing/popen_fork.pyi b/stdlib/multiprocessing/popen_fork.pyi index 5e53b055cc79..fe52afed7cfe 100644 --- a/stdlib/multiprocessing/popen_fork.pyi +++ b/stdlib/multiprocessing/popen_fork.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from typing import ClassVar from .process import BaseProcess @@ -17,7 +18,7 @@ if sys.platform != "win32": def __init__(self, process_obj: BaseProcess) -> None: ... def duplicate_for_child(self, fd: int) -> int: ... def poll(self, flag: int = 1) -> int | None: ... - def wait(self, timeout: float | None = None) -> int | None: ... + def wait(self, timeout: FloatInt | None = None) -> int | None: ... if sys.version_info >= (3, 14): def interrupt(self) -> None: ... diff --git a/stdlib/multiprocessing/popen_spawn_win32.pyi b/stdlib/multiprocessing/popen_spawn_win32.pyi index 481b9eec5a37..7ba78b0d85d9 100644 --- a/stdlib/multiprocessing/popen_spawn_win32.pyi +++ b/stdlib/multiprocessing/popen_spawn_win32.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from multiprocessing.process import BaseProcess from typing import ClassVar, Final @@ -21,7 +22,7 @@ if sys.platform == "win32": def __init__(self, process_obj: BaseProcess) -> None: ... def duplicate_for_child(self, handle: int) -> int: ... - def wait(self, timeout: float | None = None) -> int | None: ... + def wait(self, timeout: FloatInt | None = None) -> int | None: ... def poll(self) -> int | None: ... def terminate(self) -> None: ... diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 1975da301ed0..d5a34e3d79a7 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from collections.abc import Callable, Iterable, Mapping from typing import Any @@ -41,7 +42,7 @@ class BaseProcess: def terminate(self) -> None: ... def kill(self) -> None: ... def close(self) -> None: ... - def join(self, timeout: float | None = None) -> None: ... + def join(self, timeout: FloatInt | None = None) -> None: ... def is_alive(self) -> bool: ... @property def exitcode(self) -> int | None: ... diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index 8f0feb834619..03ba7bb63352 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from types import GenericAlias from typing import Any, Generic, NewType, TypeVar @@ -16,8 +17,8 @@ class Queue(Generic[_T]): def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ... def __getstate__(self) -> _QueueState: ... def __setstate__(self, state: _QueueState) -> None: ... - def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ... - def get(self, block: bool = True, timeout: float | None = None) -> _T: ... + def put(self, obj: _T, block: bool = True, timeout: FloatInt | None = None) -> None: ... + def get(self, block: bool = True, timeout: FloatInt | None = None) -> _T: ... def qsize(self) -> int: ... def empty(self) -> bool: ... def full(self) -> bool: ... diff --git a/stdlib/multiprocessing/resource_sharer.pyi b/stdlib/multiprocessing/resource_sharer.pyi index 5fee7cf31e17..6ac2b005ef55 100644 --- a/stdlib/multiprocessing/resource_sharer.pyi +++ b/stdlib/multiprocessing/resource_sharer.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from socket import socket __all__ = ["stop"] @@ -17,4 +18,4 @@ else: def __init__(self, fd: int) -> None: ... def detach(self) -> int: ... -def stop(timeout: float | None = None) -> None: ... +def stop(timeout: FloatInt | None = None) -> None: ... diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 90777a4e771b..b2ef8d8bbf36 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -6,7 +6,7 @@ from typing_extensions import Self __all__ = ["SharedMemory", "ShareableList"] -_SLT = TypeVar("_SLT", int, float, bool, str, bytes, None) +_SLT = TypeVar("_SLT", float, int, bool, str, bytes, None) class SharedMemory: if sys.version_info >= (3, 13): diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 693fd2f70139..d9fa738ab939 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -1,5 +1,6 @@ import ctypes from _ctypes import _CData +from _typeshed import FloatInt from collections.abc import Callable, Iterable, Sequence from ctypes import _SimpleCData, c_char from multiprocessing.context import BaseContext @@ -89,7 +90,7 @@ def synchronized(obj: _CT, lock: _LockLike | None = None, ctx: Any | None = None @type_check_only class _AcquireFunc(Protocol): - def __call__(self, block: bool = ..., timeout: float | None = ..., /) -> bool: ... + def __call__(self, block: bool = ..., timeout: FloatInt | None = ..., /) -> bool: ... class SynchronizedBase(Generic[_CT]): acquire: _AcquireFunc diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 889e71c061e1..a61fbb293d73 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -1,5 +1,6 @@ import sys import threading +from _typeshed import FloatInt from collections.abc import Callable from multiprocessing.context import BaseContext from types import TracebackType @@ -11,22 +12,22 @@ _LockLike: TypeAlias = Lock | RLock class Barrier(threading.Barrier): def __init__( - self, parties: int, action: Callable[[], object] | None = None, timeout: float | None = None, *, ctx: BaseContext + self, parties: int, action: Callable[[], object] | None = None, timeout: FloatInt | None = None, *, ctx: BaseContext ) -> None: ... class Condition: def __init__(self, lock: _LockLike | None = None, *, ctx: BaseContext) -> None: ... def notify(self, n: int = 1) -> None: ... def notify_all(self) -> None: ... - def wait(self, timeout: float | None = None) -> bool: ... - def wait_for(self, predicate: Callable[[], bool], timeout: float | None = None) -> bool: ... + def wait(self, timeout: FloatInt | None = None) -> bool: ... + def wait_for(self, predicate: Callable[[], bool], timeout: FloatInt | None = None) -> bool: ... def __enter__(self) -> bool: ... def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, / ) -> None: ... # These methods are copied from the lock passed to the constructor, or an # instance of ctx.RLock() if lock was None. - def acquire(self, block: bool = True, timeout: float | None = None) -> bool: ... + def acquire(self, block: bool = True, timeout: FloatInt | None = None) -> bool: ... def release(self) -> None: ... class Event: @@ -34,7 +35,7 @@ class Event: def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... - def wait(self, timeout: float | None = None) -> bool: ... + def wait(self, timeout: FloatInt | None = None) -> bool: ... # Not part of public API class SemLock: @@ -44,7 +45,7 @@ class SemLock: self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, / ) -> None: ... # These methods are copied from the wrapped _multiprocessing.SemLock object - def acquire(self, block: bool = True, timeout: float | None = None) -> bool: ... + def acquire(self, block: bool = True, timeout: FloatInt | None = None) -> bool: ... def release(self) -> None: ... if sys.version_info >= (3, 14): def locked(self) -> bool: ... diff --git a/stdlib/multiprocessing/util.pyi b/stdlib/multiprocessing/util.pyi index 5eb31de77f0f..403c8cbe9aa4 100644 --- a/stdlib/multiprocessing/util.pyi +++ b/stdlib/multiprocessing/util.pyi @@ -1,6 +1,6 @@ import sys import threading -from _typeshed import ConvertibleToInt, Incomplete, Unused +from _typeshed import ConvertibleToInt, FloatInt, Incomplete, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from logging import Logger, _Level as _LoggingLevel from typing import Any, Final, Generic, TypeVar, overload @@ -96,7 +96,7 @@ class Finalize(Generic[_R_co]): def is_exiting() -> bool: ... class ForkAwareThreadLock: - acquire: Callable[[bool, float], bool] + acquire: Callable[[bool, FloatInt], bool] release: Callable[[], None] def __enter__(self) -> bool: ... def __exit__(self, *args: Unused) -> None: ... diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 926b07be79e6..df58e0285613 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -1,7 +1,7 @@ import datetime import socket import ssl -from _typeshed import Unused +from _typeshed import FloatInt, Unused from builtins import list as _list # conflicts with a method named "list" from collections.abc import Iterable from typing import IO, Any, Final, NamedTuple, TypeAlias @@ -69,7 +69,7 @@ class NNTP: password: str | None = None, readermode: bool | None = None, usenetrc: bool = False, - timeout: float = ..., + timeout: FloatInt = ..., ) -> None: ... def __enter__(self) -> Self: ... def __exit__(self, *args: Unused) -> None: ... @@ -116,5 +116,5 @@ class NNTP_SSL(NNTP): ssl_context: ssl.SSLContext | None = None, readermode: bool | None = None, usenetrc: bool = False, - timeout: float = ..., + timeout: FloatInt = ..., ) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 008a8d607211..72edbff33033 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -5,6 +5,7 @@ from _typeshed import ( FileDescriptor, FileDescriptorLike, FileDescriptorOrPath, + FloatInt, GenericPath, OpenBinaryMode, OpenBinaryModeReading, @@ -1446,7 +1447,7 @@ def truncate(path: FileDescriptorOrPath, length: int) -> None: ... # Unix only def unlink(path: StrOrBytesPath, *, dir_fd: int | None = None) -> None: ... def utime( path: FileDescriptorOrPath, - times: tuple[int, int] | tuple[float, float] | None = None, + times: tuple[int, int] | tuple[FloatInt, FloatInt] | None = None, *, ns: tuple[int, int] = ..., dir_fd: int | None = None, @@ -1884,7 +1885,7 @@ if sys.version_info >= (3, 13) and sys.platform == "linux": def timerfd_create(clockid: int, /, *, flags: int = 0) -> int: ... def timerfd_settime( - fd: FileDescriptor, /, *, flags: int = 0, initial: float = 0.0, interval: float = 0.0 + fd: FileDescriptor, /, *, flags: int = 0, initial: FloatInt = 0.0, interval: FloatInt = 0.0 ) -> tuple[float, float]: ... def timerfd_settime_ns(fd: FileDescriptor, /, *, flags: int = 0, initial: int = 0, interval: int = 0) -> tuple[int, int]: ... def timerfd_gettime(fd: FileDescriptor, /) -> tuple[float, float]: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index dc3247ee47fb..5604249c9ef1 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer +from _typeshed import FloatInt, ReadableBuffer from collections.abc import Mapping, MutableMapping from datetime import datetime from enum import Enum @@ -38,7 +38,7 @@ else: if sys.version_info >= (3, 13): def dump( - value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | FloatInt | bytes | bytearray | datetime, fp: IO[bytes], *, fmt: PlistFormat = ..., @@ -47,7 +47,7 @@ if sys.version_info >= (3, 13): aware_datetime: bool = False, ) -> None: ... def dumps( - value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | FloatInt | bytes | bytearray | datetime, *, fmt: PlistFormat = ..., skipkeys: bool = False, @@ -57,7 +57,7 @@ if sys.version_info >= (3, 13): else: def dump( - value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | FloatInt | bytes | bytearray | datetime, fp: IO[bytes], *, fmt: PlistFormat = ..., @@ -65,7 +65,7 @@ else: skipkeys: bool = False, ) -> None: ... def dumps( - value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | FloatInt | bytes | bytearray | datetime, *, fmt: PlistFormat = ..., skipkeys: bool = False, diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 59d95c0882f1..13c946d46756 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -1,7 +1,7 @@ import socket import ssl import sys -from _typeshed import StrOrBytesPath +from _typeshed import FloatInt, StrOrBytesPath from builtins import list as _list # conflicts with a method named "list" from re import Pattern from typing import Any, BinaryIO, Final, TypeAlias, overload @@ -27,7 +27,7 @@ class POP3: sock: socket.socket file: BinaryIO welcome: bytes - def __init__(self, host: str, port: int = 110, timeout: float = ...) -> None: ... + def __init__(self, host: str, port: int = 110, timeout: FloatInt = ...) -> None: ... def getwelcome(self) -> bytes: ... def set_debuglevel(self, level: int) -> None: ... def user(self, user: str) -> bytes: ... @@ -57,7 +57,7 @@ class POP3: class POP3_SSL(POP3): if sys.version_info >= (3, 12): def __init__( - self, host: str, port: int = 995, *, timeout: float = ..., context: ssl.SSLContext | None = None + self, host: str, port: int = 995, *, timeout: FloatInt = ..., context: ssl.SSLContext | None = None ) -> None: ... def stls(self, context: Any = None) -> Never: ... else: @@ -68,7 +68,7 @@ class POP3_SSL(POP3): port: int = 995, keyfile: None = None, certfile: None = None, - timeout: float = ..., + timeout: FloatInt = ..., context: ssl.SSLContext | None = None, ) -> None: ... @overload @@ -82,7 +82,7 @@ class POP3_SSL(POP3): port: int = 995, keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, - timeout: float = ..., + timeout: FloatInt = ..., context: None = None, ) -> None: ... diff --git a/stdlib/profiling/sampling/gecko_collector.pyi b/stdlib/profiling/sampling/gecko_collector.pyi index 666fd42c3ea5..0f941a740657 100644 --- a/stdlib/profiling/sampling/gecko_collector.pyi +++ b/stdlib/profiling/sampling/gecko_collector.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete, StrOrBytesPath, StrPath +from _typeshed import FloatInt, Incomplete, StrOrBytesPath, StrPath from collections.abc import Generator, Sequence from tempfile import TemporaryDirectory from typing import Any, ClassVar, Final, TypedDict, type_check_only @@ -61,9 +61,9 @@ class GeckoThreadSpill: sample_count: int marker_count: int def __init__(self, directory: StrPath, tid: int) -> None: ... - def append_sample(self, stack_index: int, time_ms: float) -> None: ... + def append_sample(self, stack_index: int, time_ms: FloatInt) -> None: ... def append_marker( - self, name_idx: int, start_time: float, end_time: float, phase: int, category: int, data: dict[str, Any] + self, name_idx: int, start_time: FloatInt, end_time: FloatInt, phase: int, category: int, data: dict[str, Any] ) -> None: ... def prepare_read(self) -> None: ... @@ -73,7 +73,7 @@ class GeckoCollector(Collector): sample_interval_usec: int skip_idle: bool opcodes_enabled: bool - start_time: float + start_time: FloatInt global_strings: list[str] global_string_map: dict[str, int] @@ -85,8 +85,8 @@ class GeckoCollector(Collector): libs: list[Incomplete] sample_count: int - last_sample_time: float - interval: float + last_sample_time: FloatInt + interval: FloatInt has_gil_start: dict[Incomplete, Incomplete] no_gil_start: dict[Incomplete, Incomplete] @@ -98,11 +98,11 @@ class GeckoCollector(Collector): exception_start: dict[Incomplete, Incomplete] no_exception_start: dict[Incomplete, Incomplete] - gc_start_per_thread: dict[int, float] + gc_start_per_thread: dict[int, FloatInt] initialized_threads: set[Incomplete] - opcode_state: dict[int, tuple[Incomplete, int, int, str, str, float]] + opcode_state: dict[int, tuple[Incomplete, int, int, str, str, FloatInt]] def __init__(self, sample_interval_usec: int, *, skip_idle: bool = False, opcodes: bool = False) -> None: ... def collect( diff --git a/stdlib/profiling/sampling/heatmap_collector.pyi b/stdlib/profiling/sampling/heatmap_collector.pyi index bd523bc38245..88fb92b9e29b 100644 --- a/stdlib/profiling/sampling/heatmap_collector.pyi +++ b/stdlib/profiling/sampling/heatmap_collector.pyi @@ -1,4 +1,4 @@ -from _typeshed import StrOrBytesPath +from _typeshed import FloatInt, StrOrBytesPath from collections.abc import Sequence from _remote_debugging import AwaitedInfo, InterpreterInfo @@ -16,9 +16,9 @@ class HeatmapCollector(Collector): def set_stats( self, sample_interval_usec: int, - duration_sec: float, - sample_rate: float, - error_rate: float | None = None, - missed_samples: float | None = None, + duration_sec: FloatInt, + sample_rate: FloatInt, + error_rate: FloatInt | None = None, + missed_samples: FloatInt | None = None, **kwargs: object, ) -> None: ... diff --git a/stdlib/profiling/sampling/stack_collector.pyi b/stdlib/profiling/sampling/stack_collector.pyi index 8ea1db6bc41c..62f714620de4 100644 --- a/stdlib/profiling/sampling/stack_collector.pyi +++ b/stdlib/profiling/sampling/stack_collector.pyi @@ -1,4 +1,4 @@ -from _typeshed import StrOrBytesPath, SupportsGet, SupportsKeysAndGet +from _typeshed import FloatInt, StrOrBytesPath, SupportsGet, SupportsKeysAndGet from abc import ABCMeta from collections import Counter from collections.abc import Sequence @@ -32,10 +32,10 @@ class CollapsedStackCollector(StackTraceCollector): @type_check_only class _FlamegraphCollectorStats(TypedDict, total=False): sample_interval_usec: Required[int] - duration_sec: float - sample_rate: float - error_rate: float | None - missed_samples: float | None + duration_sec: FloatInt + sample_rate: FloatInt + error_rate: FloatInt | None + missed_samples: FloatInt | None mode: int | None @type_check_only @@ -60,13 +60,13 @@ class FlamegraphCollector(StackTraceCollector): def set_stats( self, sample_interval_usec: int, - duration_sec: float, - sample_rate: float, - error_rate: float | None = None, - missed_samples: float | None = None, + duration_sec: FloatInt, + sample_rate: FloatInt, + error_rate: FloatInt | None = None, + missed_samples: FloatInt | None = None, mode: int | None = None, ) -> None: ... - def set_replay_stats(self, info: SupportsGet[str, float | None]) -> None: ... + def set_replay_stats(self, info: SupportsGet[str, FloatInt | None]) -> None: ... def set_mode(self, mode: int | None) -> None: ... def export(self, filename: StrOrBytesPath) -> None: ... def process_frames(self, frames: Sequence[_Frame], thread_id: int, weight: int = 1) -> None: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 8f244fde02c3..8b448da5d0cf 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import StrOrBytesPath +from _typeshed import FloatInt, StrOrBytesPath from collections.abc import Iterable from cProfile import Profile as _cProfile from dataclasses import dataclass @@ -43,16 +43,16 @@ else: @dataclass(unsafe_hash=True) class FunctionProfile: ncalls: str - tottime: float - percall_tottime: float - cumtime: float - percall_cumtime: float + tottime: FloatInt + percall_tottime: FloatInt + cumtime: FloatInt + percall_cumtime: FloatInt file_name: str line_number: int @dataclass(unsafe_hash=True) class StatsProfile: - total_tt: float + total_tt: FloatInt func_profiles: dict[str, FunctionProfile] _SortArgDict: TypeAlias = dict[str, tuple[tuple[tuple[int, int], ...], str]] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index de2471f92acd..57190d1d42cb 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,4 +1,4 @@ -from _typeshed import ReadableBuffer, SupportsRead +from _typeshed import FloatInt, ReadableBuffer, SupportsRead from collections.abc import Callable from pyexpat import errors as errors, model as model from typing import Any, Final, TypeAlias, final @@ -31,10 +31,10 @@ class XMLParserType: def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ... # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... - def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... + def SetAllocTrackerMaximumAmplification(self, max_factor: FloatInt, /) -> None: ... # Added in Python 3.10.19, 3.11.14, 3.12.12, 3.13.4, 3.14.6 def SetBillionLaughsAttackProtectionActivationThreshold(self, threshold: int, /) -> None: ... - def SetBillionLaughsAttackProtectionMaximumAmplification(self, max_factor: float, /) -> None: ... + def SetBillionLaughsAttackProtectionMaximumAmplification(self, max_factor: FloatInt, /) -> None: ... @property def intern(self) -> dict[str, str]: ... buffer_size: int diff --git a/stdlib/queue.pyi b/stdlib/queue.pyi index 65e2ac1559ad..38c40cb047e7 100644 --- a/stdlib/queue.pyi +++ b/stdlib/queue.pyi @@ -1,6 +1,6 @@ import sys from _queue import Empty as Empty, SimpleQueue as SimpleQueue -from _typeshed import SupportsRichComparisonT +from _typeshed import FloatInt, SupportsRichComparisonT from threading import Condition, Lock from types import GenericAlias from typing import Any, Generic, TypeVar @@ -33,13 +33,13 @@ class Queue(Generic[_T]): def _init(self, maxsize: int) -> None: ... def empty(self) -> bool: ... def full(self) -> bool: ... - def get(self, block: bool = True, timeout: float | None = None) -> _T: ... + def get(self, block: bool = True, timeout: FloatInt | None = None) -> _T: ... def get_nowait(self) -> _T: ... if sys.version_info >= (3, 13): def shutdown(self, immediate: bool = False) -> None: ... def _get(self) -> _T: ... - def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... + def put(self, item: _T, block: bool = True, timeout: FloatInt | None = None) -> None: ... def put_nowait(self, item: _T) -> None: ... def _put(self, item: _T) -> None: ... def join(self) -> None: ... diff --git a/stdlib/random.pyi b/stdlib/random.pyi index c70c8364684c..607da20b85fc 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -1,6 +1,6 @@ import _random import sys -from _typeshed import SupportsLenAndGetItem +from _typeshed import FloatInt, SupportsLenAndGetItem from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet from fractions import Fraction from typing import Any, ClassVar, TypeVar, overload @@ -41,12 +41,8 @@ _T = TypeVar("_T") class Random(_random.Random): VERSION: ClassVar[int] - def __init__(self, x: int | float | str | bytes | bytearray | None = None) -> None: ... # noqa: Y041 - # Using other `seed` types is deprecated since 3.9 and removed in 3.11 - # Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit - # int better documents conventional usage of random.seed. - - def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041 + def __init__(self, x: float | int | str | bytes | bytearray | None = None) -> None: ... + def seed(self, a: float | int | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] def getstate(self) -> tuple[Any, ...]: ... def setstate(self, state: tuple[Any, ...]) -> None: ... def randrange(self, start: int, stop: int | None = None, step: int = 1) -> int: ... @@ -56,9 +52,9 @@ class Random(_random.Random): def choices( self, population: SupportsLenAndGetItem[_T], - weights: Sequence[float | Fraction] | None = None, + weights: Sequence[FloatInt | Fraction] | None = None, *, - cum_weights: Sequence[float | Fraction] | None = None, + cum_weights: Sequence[FloatInt | Fraction] | None = None, k: int = 1, ) -> list[_T]: ... if sys.version_info >= (3, 11): @@ -77,29 +73,29 @@ class Random(_random.Random): self, population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[int] | None = None ) -> list[_T]: ... - def uniform(self, a: float, b: float) -> float: ... - def triangular(self, low: float = 0.0, high: float = 1.0, mode: float | None = None) -> float: ... + def uniform(self, a: FloatInt, b: FloatInt) -> float: ... + def triangular(self, low: FloatInt = 0.0, high: FloatInt = 1.0, mode: FloatInt | None = None) -> float: ... if sys.version_info >= (3, 12): - def binomialvariate(self, n: int = 1, p: float = 0.5) -> int: ... + def binomialvariate(self, n: int = 1, p: FloatInt = 0.5) -> int: ... - def betavariate(self, alpha: float, beta: float) -> float: ... + def betavariate(self, alpha: FloatInt, beta: FloatInt) -> float: ... if sys.version_info >= (3, 12): - def expovariate(self, lambd: float = 1.0) -> float: ... + def expovariate(self, lambd: FloatInt = 1.0) -> float: ... else: - def expovariate(self, lambd: float) -> float: ... + def expovariate(self, lambd: FloatInt) -> float: ... - def gammavariate(self, alpha: float, beta: float) -> float: ... + def gammavariate(self, alpha: FloatInt, beta: FloatInt) -> float: ... if sys.version_info >= (3, 11): - def gauss(self, mu: float = 0.0, sigma: float = 1.0) -> float: ... - def normalvariate(self, mu: float = 0.0, sigma: float = 1.0) -> float: ... + def gauss(self, mu: FloatInt = 0.0, sigma: FloatInt = 1.0) -> float: ... + def normalvariate(self, mu: FloatInt = 0.0, sigma: FloatInt = 1.0) -> float: ... else: - def gauss(self, mu: float, sigma: float) -> float: ... - def normalvariate(self, mu: float, sigma: float) -> float: ... + def gauss(self, mu: FloatInt, sigma: FloatInt) -> float: ... + def normalvariate(self, mu: FloatInt, sigma: FloatInt) -> float: ... - def lognormvariate(self, mu: float, sigma: float) -> float: ... - def vonmisesvariate(self, mu: float, kappa: float) -> float: ... - def paretovariate(self, alpha: float) -> float: ... - def weibullvariate(self, alpha: float, beta: float) -> float: ... + def lognormvariate(self, mu: FloatInt, sigma: FloatInt) -> float: ... + def vonmisesvariate(self, mu: FloatInt, kappa: FloatInt) -> float: ... + def paretovariate(self, alpha: FloatInt) -> float: ... + def weibullvariate(self, alpha: FloatInt, beta: FloatInt) -> float: ... # SystemRandom is not implemented for all OS's; good on Windows & Linux class SystemRandom(Random): diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 54eb6ed0cd53..cd63d777ab12 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,4 +1,5 @@ import time +from _typeshed import FloatInt from collections.abc import Callable from typing import Any, NamedTuple, TypeAlias @@ -7,7 +8,7 @@ __all__ = ["scheduler"] _ActionCallback: TypeAlias = Callable[..., Any] class Event(NamedTuple): - time: float + time: FloatInt priority: Any sequence: int action: _ActionCallback @@ -16,16 +17,21 @@ class Event(NamedTuple): class scheduler: timefunc: Callable[[], float] - delayfunc: Callable[[float], object] + delayfunc: Callable[[FloatInt], object] def __init__( - self, timefunc: Callable[[], float] = time.monotonic, delayfunc: Callable[[float], object] = time.sleep + self, timefunc: Callable[[], float] = time.monotonic, delayfunc: Callable[[FloatInt], object] = time.sleep ) -> None: ... def enterabs( - self, time: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = (), kwargs: dict[str, Any] = ... + self, time: FloatInt, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = (), kwargs: dict[str, Any] = ... ) -> Event: ... def enter( - self, delay: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = (), kwargs: dict[str, Any] = ... + self, + delay: FloatInt, + priority: Any, + action: _ActionCallback, + argument: tuple[Any, ...] = (), + kwargs: dict[str, Any] = ..., ) -> Event: ... def run(self, blocking: bool = True) -> float | None: ... def cancel(self, event: Event) -> None: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index ad93cb0b7055..b2ccce907835 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import FileDescriptorLike +from _typeshed import FileDescriptorLike, FloatInt from collections.abc import Iterable from types import TracebackType from typing import Any, ClassVar, Final, TypeVar, final, overload @@ -30,14 +30,14 @@ if sys.platform != "win32": def register(self, fd: FileDescriptorLike, eventmask: int = 7, /) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int, /) -> None: ... def unregister(self, fd: FileDescriptorLike, /) -> None: ... - def poll(self, timeout: float | None = None, /) -> list[tuple[int, int]]: ... + def poll(self, timeout: FloatInt | None = None, /) -> list[tuple[int, int]]: ... _R = TypeVar("_R", default=Never, bound=FileDescriptorLike) _W = TypeVar("_W", default=Never, bound=FileDescriptorLike) _X = TypeVar("_X", default=Never, bound=FileDescriptorLike) def select( - rlist: Iterable[_R], wlist: Iterable[_W], xlist: Iterable[_X], timeout: float | None = None, / + rlist: Iterable[_R], wlist: Iterable[_W], xlist: Iterable[_X], timeout: FloatInt | None = None, / ) -> tuple[list[_R], list[_W], list[_X]]: ... error = OSError @@ -64,7 +64,7 @@ if sys.platform != "linux" and sys.platform != "win32": def __init__(self) -> None: ... def close(self) -> None: ... def control( - self, changelist: Iterable[kevent] | None, maxevents: int, timeout: float | None = None, / + self, changelist: Iterable[kevent] | None, maxevents: int, timeout: FloatInt | None = None, / ) -> list[kevent]: ... def fileno(self) -> int: ... @classmethod @@ -136,7 +136,7 @@ if sys.platform == "linux": def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = None, maxevents: int = -1) -> list[tuple[int, int]]: ... + def poll(self, timeout: FloatInt | None = None, maxevents: int = -1) -> list[tuple[int, int]]: ... @classmethod def fromfd(cls, fd: FileDescriptorLike, /) -> epoll: ... @@ -168,4 +168,4 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = None) -> list[tuple[int, int]]: ... + def poll(self, timeout: FloatInt | None = None) -> list[tuple[int, int]]: ... diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index 4a3478a67552..8b0203e4c10c 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import FileDescriptor, FileDescriptorLike, Unused +from _typeshed import FileDescriptor, FileDescriptorLike, FloatInt, Unused from abc import ABCMeta, abstractmethod from collections.abc import Mapping from typing import Any, Final, NamedTuple @@ -21,7 +21,7 @@ class BaseSelector(metaclass=ABCMeta): def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... def modify(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ... @abstractmethod - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ... + def select(self, timeout: FloatInt | None = None) -> list[tuple[SelectorKey, int]]: ... def close(self) -> None: ... def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ... @abstractmethod @@ -36,10 +36,10 @@ class _BaseSelectorImpl(BaseSelector, metaclass=ABCMeta): def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class SelectSelector(_BaseSelectorImpl): - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ... + def select(self, timeout: FloatInt | None = None) -> list[tuple[SelectorKey, int]]: ... class _PollLikeSelector(_BaseSelectorImpl): - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ... + def select(self, timeout: FloatInt | None = None) -> list[tuple[SelectorKey, int]]: ... if sys.platform != "win32": class PollSelector(_PollLikeSelector): ... @@ -56,12 +56,12 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win if sys.platform != "win32" and sys.platform != "linux": class KqueueSelector(_BaseSelectorImpl): def fileno(self) -> int: ... - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ... + def select(self, timeout: FloatInt | None = None) -> list[tuple[SelectorKey, int]]: ... # Not a real class at runtime, it is just a conditional alias to other real selectors. # The runtime logic is more fine-grained than a `sys.platform` check; # not really expressible in the stubs class DefaultSelector(_BaseSelectorImpl): - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ... + def select(self, timeout: FloatInt | None = None) -> list[tuple[SelectorKey, int]]: ... if sys.platform != "win32": def fileno(self) -> int: ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index a6a8853671e2..d673ed78501e 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import structseq +from _typeshed import FloatInt, structseq from collections.abc import Callable, Iterable from enum import IntEnum from types import FrameType @@ -130,7 +130,7 @@ else: def pause() -> None: ... def pthread_kill(thread_id: int, signalnum: int, /) -> None: ... def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... - def setitimer(which: int, seconds: float, interval: float = 0.0, /) -> tuple[float, float]: ... + def setitimer(which: int, seconds: FloatInt, interval: FloatInt = 0.0, /) -> tuple[float, float]: ... def siginterrupt(signalnum: int, flag: bool, /) -> None: ... def sigpending() -> Any: ... def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... @@ -162,7 +162,7 @@ else: @property def si_band(self) -> int: ... - def sigtimedwait(sigset: Iterable[int], timeout: float, /) -> struct_siginfo | None: ... + def sigtimedwait(sigset: Iterable[int], timeout: FloatInt, /) -> struct_siginfo | None: ... def sigwaitinfo(sigset: Iterable[int], /) -> struct_siginfo: ... def strsignal(signalnum: _SIGNUM, /) -> str | None: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 1aaa5b49664b..788d89f31e88 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -1,6 +1,6 @@ import sys from _socket import _Address as _SourceAddress -from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath +from _typeshed import FloatInt, ReadableBuffer, SizedBuffer, StrOrBytesPath from collections.abc import Sequence from email.message import Message as _Message from re import Pattern @@ -83,7 +83,7 @@ class SMTP: ehlo_resp: bytes | None does_esmtp: bool default_port: int - timeout: float + timeout: FloatInt esmtp_features: dict[str, str] command_encoding: str source_address: _SourceAddress | None @@ -93,7 +93,7 @@ class SMTP: host: str = "", port: int = 0, local_hostname: str | None = None, - timeout: float = ..., + timeout: FloatInt = ..., source_address: _SourceAddress | None = None, ) -> None: ... def __enter__(self) -> Self: ... @@ -173,7 +173,7 @@ class SMTP_SSL(SMTP): port: int = 0, local_hostname: str | None = None, *, - timeout: float = ..., + timeout: FloatInt = ..., source_address: _SourceAddress | None = None, context: SSLContext | None = None, ) -> None: ... @@ -186,7 +186,7 @@ class SMTP_SSL(SMTP): local_hostname: str | None = None, keyfile: None = None, certfile: None = None, - timeout: float = ..., + timeout: FloatInt = ..., source_address: _SourceAddress | None = None, context: SSLContext | None = None, ) -> None: ... @@ -202,7 +202,7 @@ class SMTP_SSL(SMTP): local_hostname: str | None = None, keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, - timeout: float = ..., + timeout: FloatInt = ..., source_address: _SourceAddress | None = None, context: None = None, ) -> None: ... @@ -219,5 +219,5 @@ class LMTP(SMTP): port: int = 2003, local_hostname: str | None = None, source_address: _SourceAddress | None = None, - timeout: float = ..., + timeout: FloatInt = ..., ) -> None: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 948092d3ce18..4373c422752e 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -133,7 +133,7 @@ from _socket import ( ntohs as ntohs, setdefaulttimeout as setdefaulttimeout, ) -from _typeshed import ReadableBuffer, Unused, WriteableBuffer +from _typeshed import FloatInt, ReadableBuffer, Unused, WriteableBuffer from collections.abc import Iterable from enum import IntEnum, IntFlag from io import BufferedReader, BufferedRWPair, BufferedWriter, RawIOBase, TextIOWrapper @@ -1565,7 +1565,7 @@ def getfqdn(name: str = "") -> str: ... if sys.version_info >= (3, 11): def create_connection( address: tuple[str | None, bytes | str | int | None], - timeout: float | None = ..., + timeout: FloatInt | None = ..., source_address: _Address | None = None, *, all_errors: bool = False, @@ -1573,7 +1573,7 @@ if sys.version_info >= (3, 11): else: def create_connection( - address: tuple[str | None, int], timeout: float | None = ..., source_address: _Address | None = None + address: tuple[str | None, int], timeout: FloatInt | None = ..., source_address: _Address | None = None ) -> socket: ... def has_dualstack_ipv6() -> bool: ... diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 05e0025d6a15..ce9f85e74998 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -1,7 +1,7 @@ import sys import types from _socket import _Address, _RetAddress -from _typeshed import ReadableBuffer +from _typeshed import FloatInt, ReadableBuffer from collections.abc import Callable from io import BufferedIOBase from socket import socket as _socket @@ -40,13 +40,13 @@ _AfInet6Address: TypeAlias = tuple[str | bytes | bytearray, int, int, int] # ad # This can possibly be generic at some point: class BaseServer: server_address: _Address - timeout: float | None + timeout: FloatInt | None RequestHandlerClass: Callable[[Any, _RetAddress, Self], BaseRequestHandler] def __init__( self, server_address: _Address, RequestHandlerClass: Callable[[Any, _RetAddress, Self], BaseRequestHandler] ) -> None: ... def handle_request(self) -> None: ... - def serve_forever(self, poll_interval: float = 0.5) -> None: ... + def serve_forever(self, poll_interval: FloatInt = 0.5) -> None: ... def shutdown(self) -> None: ... def server_close(self) -> None: ... def finish_request(self, request: _RequestType, client_address: _RetAddress) -> None: ... @@ -108,7 +108,7 @@ if sys.platform != "win32": if sys.platform != "win32": class ForkingMixIn: - timeout: float | None # undocumented + timeout: FloatInt | None # undocumented active_children: set[int] | None # undocumented max_children: int # undocumented block_on_close: bool @@ -157,7 +157,7 @@ class BaseRequestHandler: class StreamRequestHandler(BaseRequestHandler): rbufsize: ClassVar[int] # undocumented wbufsize: ClassVar[int] # undocumented - timeout: ClassVar[float | None] # undocumented + timeout: ClassVar[FloatInt | None] # undocumented disable_nagle_algorithm: ClassVar[bool] # undocumented connection: Any # undocumented rfile: BufferedIOBase diff --git a/stdlib/sqlite3/__init__.pyi b/stdlib/sqlite3/__init__.pyi index 80a02079dd05..d71d615844a0 100644 --- a/stdlib/sqlite3/__init__.pyi +++ b/stdlib/sqlite3/__init__.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsLenAndGetItem, Unused +from _typeshed import FloatInt, MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsLenAndGetItem, Unused from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence from sqlite3.dbapi2 import ( PARSE_COLNAMES as PARSE_COLNAMES, @@ -215,7 +215,7 @@ if sys.version_info < (3, 12): from sqlite3.dbapi2 import enable_shared_cache as enable_shared_cache, version as version _CursorT = TypeVar("_CursorT", bound=Cursor) -_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None +_SqliteData: TypeAlias = str | ReadableBuffer | float | int | None # Data that is passed through adapters can be of any type accepted by an adapter. _AdaptedInputData: TypeAlias = _SqliteData | Any # The Mapping must really be a dict, but making it invariant is too annoying. @@ -319,7 +319,7 @@ class Connection: def __init__( self, database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, @@ -332,7 +332,7 @@ class Connection: def __init__( self, database: StrOrBytesPath, - timeout: float = 5.0, + timeout: FloatInt = 5.0, detect_types: int = 0, isolation_level: _IsolationLevel = "DEFERRED", check_same_thread: bool = True, @@ -419,7 +419,7 @@ class Connection: pages: int = -1, progress: Callable[[int, int, int], object] | None = None, name: str = "main", - sleep: float = 0.25, + sleep: FloatInt = 0.25, ) -> None: ... if sys.version_info >= (3, 11): def setlimit(self, category: int, limit: int, /) -> int: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 0cd676f9bfc8..51f6d0d9e426 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -49,6 +49,7 @@ from _sqlite3 import ( register_converter as register_converter, sqlite_version as sqlite_version, ) +from _typeshed import FloatInt from datetime import date, datetime, time from sqlite3 import ( Connection as Connection, @@ -232,9 +233,9 @@ Date = date Time = time Timestamp = datetime -def DateFromTicks(ticks: float) -> Date: ... -def TimeFromTicks(ticks: float) -> Time: ... -def TimestampFromTicks(ticks: float) -> Timestamp: ... +def DateFromTicks(ticks: FloatInt) -> Date: ... +def TimeFromTicks(ticks: FloatInt) -> Time: ... +def TimestampFromTicks(ticks: FloatInt) -> Timestamp: ... if sys.version_info < (3, 14): # Deprecated in 3.12, removed in 3.14. diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index dde30685599c..c7ea7b0762b2 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -25,7 +25,7 @@ from _ssl import ( _PasswordType as _PasswordType, # typeshed only, but re-export for other type stubs to use _SSLContext, ) -from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath, WriteableBuffer from collections.abc import Callable, Iterable from typing import Any, Final, Literal, NamedTuple, TypeAlias, TypedDict, overload, type_check_only from typing_extensions import Never, Self, deprecated @@ -359,7 +359,7 @@ def cert_time_to_seconds(cert_time: str) -> int: ... def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... def get_server_certificate( - addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None, timeout: float = ... + addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None, timeout: FloatInt = ... ) -> str: ... class TLSVersion(enum.IntEnum): diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 8cae237f7e0b..a7daf53e8244 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import SupportsRichComparisonT +from _typeshed import FloatInt, SupportsRichComparisonT from collections.abc import Callable, Hashable, Iterable, Sequence, Sized from decimal import Decimal from fractions import Fraction @@ -33,14 +33,14 @@ if sys.version_info >= (3, 13): __all__ += ["kde", "kde_random"] # Most functions in this module accept homogeneous collections of one of these types -_Number: TypeAlias = float | Decimal | Fraction -_NumberT = TypeVar("_NumberT", float, Decimal, Fraction) +_Number: TypeAlias = float | int | Decimal | Fraction +_NumberT = TypeVar("_NumberT", float, int, Decimal, Fraction) # Used in mode, multimode _HashableT = TypeVar("_HashableT", bound=Hashable) # Used in NormalDist.samples and kde_random -_Seed: TypeAlias = int | float | str | bytes | bytearray # noqa: Y041 +_Seed: TypeAlias = float | int | str | bytes | bytearray # Used in linear_regression _T_co = TypeVar("_T_co", covariant=True) @@ -67,7 +67,7 @@ if sys.version_info >= (3, 11): def median_grouped(data: Iterable[SupportsFloat], interval: SupportsFloat = 1.0) -> float: ... else: - def median_grouped(data: Iterable[_NumberT], interval: _NumberT | float = 1) -> _NumberT | float: ... + def median_grouped(data: Iterable[_NumberT], interval: _NumberT | FloatInt = 1) -> _NumberT | float: ... def mode(data: Iterable[_HashableT]) -> _HashableT: ... def multimode(data: Iterable[_HashableT]) -> list[_HashableT]: ... @@ -81,7 +81,7 @@ def variance(data: Iterable[_NumberT], xbar: _NumberT | None = None) -> _NumberT class NormalDist: __slots__ = {"_mu": "Arithmetic mean of a normal distribution", "_sigma": "Standard deviation of a normal distribution"} - def __init__(self, mu: float = 0.0, sigma: float = 1.0) -> None: ... + def __init__(self, mu: FloatInt = 0.0, sigma: FloatInt = 1.0) -> None: ... @property def mean(self) -> float: ... @property @@ -95,21 +95,21 @@ class NormalDist: @classmethod def from_samples(cls, data: Iterable[SupportsFloat]) -> Self: ... def samples(self, n: SupportsIndex, *, seed: _Seed | None = None) -> list[float]: ... - def pdf(self, x: float) -> float: ... - def cdf(self, x: float) -> float: ... - def inv_cdf(self, p: float) -> float: ... + def pdf(self, x: FloatInt) -> float: ... + def cdf(self, x: FloatInt) -> float: ... + def inv_cdf(self, p: FloatInt) -> float: ... def overlap(self, other: NormalDist) -> float: ... def quantiles(self, n: int = 4) -> list[float]: ... - def zscore(self, x: float) -> float: ... + def zscore(self, x: FloatInt) -> float: ... def __eq__(x1, x2: object) -> bool: ... - def __add__(x1, x2: float | NormalDist) -> NormalDist: ... - def __sub__(x1, x2: float | NormalDist) -> NormalDist: ... - def __mul__(x1, x2: float) -> NormalDist: ... - def __truediv__(x1, x2: float) -> NormalDist: ... + def __add__(x1, x2: FloatInt | NormalDist) -> NormalDist: ... + def __sub__(x1, x2: FloatInt | NormalDist) -> NormalDist: ... + def __mul__(x1, x2: FloatInt) -> NormalDist: ... + def __truediv__(x1, x2: FloatInt) -> NormalDist: ... def __pos__(x1) -> NormalDist: ... def __neg__(x1) -> NormalDist: ... __radd__ = __add__ - def __rsub__(x1, x2: float | NormalDist) -> NormalDist: ... + def __rsub__(x1, x2: FloatInt | NormalDist) -> NormalDist: ... __rmul__ = __mul__ def __hash__(self) -> int: ... @@ -124,8 +124,8 @@ else: def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... class LinearRegression(NamedTuple): - slope: float - intercept: float + slope: FloatInt + intercept: FloatInt if sys.version_info >= (3, 11): def linear_regression( @@ -154,8 +154,8 @@ if sys.version_info >= (3, 13): "cosine", ] def kde( - data: Sequence[float], h: float, kernel: _Kernel = "normal", *, cumulative: bool = False + data: Sequence[FloatInt], h: FloatInt, kernel: _Kernel = "normal", *, cumulative: bool = False ) -> Callable[[float], float]: ... def kde_random( - data: Sequence[float], h: float, kernel: _Kernel = "normal", *, seed: _Seed | None = None + data: Sequence[FloatInt], h: FloatInt, kernel: _Kernel = "normal", *, seed: _Seed | None = None ) -> Callable[[], float]: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 2f889d4ffc9b..7d926fb6263d 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath +from _typeshed import FloatInt, MaybeNone, ReadableBuffer, StrOrBytesPath from collections.abc import Callable, Collection, Iterable, Mapping, Sequence from types import GenericAlias, TracebackType from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, overload @@ -114,7 +114,7 @@ if sys.version_info >= (3, 11): errors: str | None = None, input: str | None = None, text: Literal[True], - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -148,7 +148,7 @@ if sys.version_info >= (3, 11): errors: str | None = None, input: str | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -182,7 +182,7 @@ if sys.version_info >= (3, 11): errors: str, input: str | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -217,7 +217,7 @@ if sys.version_info >= (3, 11): errors: str | None = None, input: str | None = None, text: Literal[True] | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -251,7 +251,7 @@ if sys.version_info >= (3, 11): errors: None = None, input: ReadableBuffer | None = None, text: Literal[False] | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -285,7 +285,7 @@ if sys.version_info >= (3, 11): errors: str | None = None, input: _InputString | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -321,7 +321,7 @@ else: errors: str | None = None, input: str | None = None, text: Literal[True], - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -354,7 +354,7 @@ else: errors: str | None = None, input: str | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -387,7 +387,7 @@ else: errors: str, input: str | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -421,7 +421,7 @@ else: errors: str | None = None, input: str | None = None, text: Literal[True] | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -454,7 +454,7 @@ else: errors: None = None, input: ReadableBuffer | None = None, text: Literal[False] | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -487,7 +487,7 @@ else: errors: str | None = None, input: _InputString | None = None, text: bool | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -519,7 +519,7 @@ if sys.version_info >= (3, 11): *, encoding: str | None = None, errors: str | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, @@ -552,7 +552,7 @@ else: *, encoding: str | None = None, errors: str | None = None, - timeout: float | None = None, + timeout: FloatInt | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, @@ -582,7 +582,7 @@ if sys.version_info >= (3, 11): restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - timeout: float | None = None, + timeout: FloatInt | None = None, *, encoding: str | None = None, errors: str | None = None, @@ -615,7 +615,7 @@ else: restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - timeout: float | None = None, + timeout: FloatInt | None = None, *, encoding: str | None = None, errors: str | None = None, @@ -648,7 +648,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -679,7 +679,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str, errors: str | None = None, @@ -710,7 +710,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str, @@ -742,7 +742,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), # where the real keyword only ones start - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -773,7 +773,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: None = None, errors: None = None, @@ -804,7 +804,7 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -837,7 +837,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -867,7 +867,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str, errors: str | None = None, @@ -897,7 +897,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str, @@ -928,7 +928,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), # where the real keyword only ones start - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -958,7 +958,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: None = None, errors: None = None, @@ -988,7 +988,7 @@ else: start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, + timeout: FloatInt | None = None, input: _InputString | None = None, encoding: str | None = None, errors: str | None = None, @@ -1008,11 +1008,11 @@ class SubprocessError(Exception): ... class TimeoutExpired(SubprocessError): def __init__( - self, cmd: _CMD, timeout: float, output: str | bytes | None = None, stderr: str | bytes | None = None + self, cmd: _CMD, timeout: FloatInt, output: str | bytes | None = None, stderr: str | bytes | None = None ) -> None: ... # morally: _CMD cmd: Any - timeout: float + timeout: FloatInt # morally: str | bytes | None output: Any stdout: bytes | None @@ -1415,11 +1415,11 @@ class Popen(Generic[AnyStr]): ) -> None: ... def poll(self) -> int | None: ... - def wait(self, timeout: float | None = None) -> int: ... + def wait(self, timeout: FloatInt | None = None) -> int: ... # morally the members of the returned tuple should be optional # TODO: this should allow ReadableBuffer for Popen[bytes], but adding # overloads for that runs into a mypy bug (python/mypy#14070). - def communicate(self, input: AnyStr | None = None, timeout: float | None = None) -> tuple[AnyStr, AnyStr]: ... + def communicate(self, input: AnyStr | None = None, timeout: FloatInt | None = None) -> tuple[AnyStr, AnyStr]: ... def send_signal(self, sig: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index e4b9fcb6b8ca..2ca87b70dcb8 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,4 +1,4 @@ -from _typeshed import Unused +from _typeshed import FloatInt, Unused from typing import IO, Any, Final, Literal, NamedTuple, TypeAlias, overload from typing_extensions import Never, Self @@ -59,7 +59,7 @@ class Au_write: def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... def getsampwidth(self) -> int: ... - def setframerate(self, framerate: float) -> None: ... + def setframerate(self, framerate: FloatInt) -> None: ... def getframerate(self) -> int: ... def setnframes(self, nframes: int) -> None: ... def getnframes(self) -> int: ... diff --git a/stdlib/sys/__init__.pyi b/stdlib/sys/__init__.pyi index 847895fb65b1..c73ff95ad80e 100644 --- a/stdlib/sys/__init__.pyi +++ b/stdlib/sys/__init__.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import MaybeNone, OptExcInfo, ProfileFunction, StrOrBytesPath, TraceFunction, structseq +from _typeshed import FloatInt, MaybeNone, OptExcInfo, ProfileFunction, StrOrBytesPath, TraceFunction, structseq from _typeshed.importlib import MetaPathFinderProtocol, PathEntryFinderProtocol from builtins import object as _object from collections.abc import AsyncGenerator, Callable, Sequence @@ -454,7 +454,7 @@ if sys.platform != "win32": def setdlopenflags(flags: int, /) -> None: ... def setrecursionlimit(limit: int, /) -> None: ... -def setswitchinterval(interval: float, /) -> None: ... +def setswitchinterval(interval: FloatInt, /) -> None: ... def gettotalrefcount() -> int: ... # Debug builds only # Doesn't exist at runtime, but exported in the stubs so pytest etc. can annotate their code more easily. diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 5def3717a0a2..90b769f69681 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -1,7 +1,7 @@ import bz2 import io import sys -from _typeshed import FileDescriptorOrPath, ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, WriteableBuffer +from _typeshed import FileDescriptorOrPath, FloatInt, ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, WriteableBuffer from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list" from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj @@ -151,7 +151,7 @@ class TarFile: errorlevel: Literal[0, 1, 2] | None = None, # default 1 copybufsize: int | None = None, # undocumented stream: bool = False, - mtime: float | None = None, + mtime: FloatInt | None = None, ) -> None: ... elif sys.version_info >= (3, 13): def __init__( @@ -793,7 +793,7 @@ class TarInfo: ) name: str size: int - mtime: int | float + mtime: float | int chksum: int devmajor: int devminor: int @@ -836,7 +836,7 @@ class TarInfo: self, *, name: str = ..., - mtime: float = ..., + mtime: FloatInt = ..., mode: int = ..., linkname: str = ..., uid: int = ..., diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 88aa43d24899..5ace1a4a6072 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -1,4 +1,5 @@ import socket +from _typeshed import FloatInt from collections.abc import Callable, MutableSequence, Sequence from re import Match, Pattern from types import TracebackType @@ -89,15 +90,15 @@ NOOPT: Final = b"\x00" class Telnet: host: str | None # undocumented sock: socket.socket | None # undocumented - def __init__(self, host: str | None = None, port: int = 0, timeout: float = ...) -> None: ... - def open(self, host: str, port: int = 0, timeout: float = ...) -> None: ... + def __init__(self, host: str | None = None, port: int = 0, timeout: FloatInt = ...) -> None: ... + def open(self, host: str, port: int = 0, timeout: FloatInt = ...) -> None: ... def msg(self, msg: str, *args: Any) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... def close(self) -> None: ... def get_socket(self) -> socket.socket: ... def fileno(self) -> int: ... def write(self, buffer: bytes) -> None: ... - def read_until(self, match: bytes, timeout: float | None = None) -> bytes: ... + def read_until(self, match: bytes, timeout: FloatInt | None = None) -> bytes: ... def read_all(self) -> bytes: ... def read_some(self) -> bytes: ... def read_very_eager(self) -> bytes: ... @@ -114,7 +115,7 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: MutableSequence[Pattern[bytes] | bytes] | Sequence[Pattern[bytes]], timeout: float | None = None + self, list: MutableSequence[Pattern[bytes] | bytes] | Sequence[Pattern[bytes]], timeout: FloatInt | None = None ) -> tuple[int, Match[bytes] | None, bytes]: ... def __enter__(self) -> Self: ... def __exit__( diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 6b51b424cee6..392491e61485 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,7 +1,7 @@ import _thread import sys from _thread import _ExceptHookArgs, get_native_id as get_native_id -from _typeshed import ProfileFunction, TraceFunction +from _typeshed import FloatInt, ProfileFunction, TraceFunction from collections.abc import Callable, Iterable, Iterator, Mapping from contextvars import Context from types import TracebackType @@ -81,7 +81,7 @@ if sys.version_info >= (3, 15): def stack_size(size: int = 0, /) -> int: ... -TIMEOUT_MAX: Final[float] +TIMEOUT_MAX: Final[FloatInt] ThreadError = _thread.error local = _thread._local @@ -117,7 +117,7 @@ class Thread: def start(self) -> None: ... def run(self) -> None: ... - def join(self, timeout: float | None = None) -> None: ... + def join(self, timeout: FloatInt | None = None) -> None: ... @property def native_id(self) -> int | None: ... # only available on some platforms def is_alive(self) -> bool: ... @@ -140,7 +140,7 @@ Lock = _thread.LockType @final class _RLock: _count: int - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... def release(self) -> None: ... __enter__ = acquire def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... @@ -156,13 +156,13 @@ class Condition: def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt = -1) -> bool: ... def release(self) -> None: ... if sys.version_info >= (3, 14): def locked(self) -> bool: ... - def wait(self, timeout: float | None = None) -> bool: ... - def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ... + def wait(self, timeout: FloatInt | None = None) -> bool: ... + def wait_for(self, predicate: Callable[[], _T], timeout: FloatInt | None = None) -> _T: ... def notify(self, n: int = 1) -> None: ... def notify_all(self) -> None: ... @deprecated("Deprecated since Python 3.10. Use `notify_all()` instead.") @@ -172,8 +172,8 @@ class Semaphore: _value: int def __init__(self, value: int = 1) -> None: ... def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... - def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ... - def __enter__(self, blocking: bool = True, timeout: float | None = None) -> bool: ... + def acquire(self, blocking: bool = True, timeout: FloatInt | None = None) -> bool: ... + def __enter__(self, blocking: bool = True, timeout: FloatInt | None = None) -> bool: ... def release(self, n: int = 1) -> None: ... class BoundedSemaphore(Semaphore): ... @@ -184,7 +184,7 @@ class Event: def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... - def wait(self, timeout: float | None = None) -> bool: ... + def wait(self, timeout: FloatInt | None = None) -> bool: ... excepthook: Callable[[_ExceptHookArgs], object] __excepthook__: Callable[[_ExceptHookArgs], object] @@ -194,12 +194,12 @@ class Timer(Thread): args: Iterable[Any] # undocumented finished: Event # undocumented function: Callable[..., Any] # undocumented - interval: float # undocumented + interval: FloatInt # undocumented kwargs: Mapping[str, Any] # undocumented def __init__( self, - interval: float, + interval: FloatInt, function: Callable[..., object], args: Iterable[Any] | None = None, kwargs: Mapping[str, Any] | None = None, @@ -213,8 +213,8 @@ class Barrier: def n_waiting(self) -> int: ... @property def broken(self) -> bool: ... - def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None) -> None: ... - def wait(self, timeout: float | None = None) -> int: ... + def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: FloatInt | None = None) -> None: ... + def wait(self, timeout: FloatInt | None = None) -> int: ... def reset(self) -> None: ... def abort(self) -> None: ... diff --git a/stdlib/time.pyi b/stdlib/time.pyi index ac53089b8d82..7dacbe6c939a 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,14 +1,13 @@ import sys -from _typeshed import structseq +from _typeshed import FloatInt, structseq from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, final, type_check_only _TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int] if sys.version_info >= (3, 15): - # anticipate on https://github.com/python/cpython/pull/139224 _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex else: - # before, time functions only accept (subclass of) float, *not* SupportsFloat + # time functions only accept float, *not* SupportsFloat _SupportsFloatOrIndex: TypeAlias = float | SupportsIndex altzone: int @@ -90,7 +89,7 @@ class _ClockInfo(Protocol): adjustable: bool implementation: str monotonic: bool - resolution: float + resolution: FloatInt def get_clock_info(name: Literal["monotonic", "perf_counter", "process_time", "time", "thread_time"], /) -> _ClockInfo: ... def monotonic() -> float: ... @@ -100,7 +99,7 @@ def process_time() -> float: ... if sys.platform != "win32": def clock_getres(clk_id: int, /) -> float: ... # Unix only def clock_gettime(clk_id: int, /) -> float: ... # Unix only - def clock_settime(clk_id: int, time: float, /) -> None: ... # Unix only + def clock_settime(clk_id: int, time: FloatInt, /) -> None: ... # Unix only if sys.platform != "win32": def clock_gettime_ns(clk_id: int, /) -> int: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index cc2b2027a820..01ce2f9480e6 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,5 +1,6 @@ import sys import time +from _typeshed import FloatInt from collections.abc import Callable, Sequence from typing import IO, Any, TypeAlias @@ -23,10 +24,10 @@ class Timer: def repeat(self, repeat: int = 5, number: int = 1000000) -> list[float]: ... if sys.version_info >= (3, 15): def autorange( - self, callback: Callable[[int, float], object] | None = None, target_time: float = 0.2 + self, callback: Callable[[int, FloatInt], object] | None = None, target_time: FloatInt = 0.2 ) -> tuple[int, float]: ... else: - def autorange(self, callback: Callable[[int, float], object] | None = None) -> tuple[int, float]: ... + def autorange(self, callback: Callable[[int, FloatInt], object] | None = None) -> tuple[int, float]: ... def timeit( stmt: _Stmt = "pass", diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 59cbc4401e51..a5d743290e40 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1,6 +1,6 @@ import _tkinter import sys -from _typeshed import FileDescriptorLike, Incomplete, MaybeNone, StrOrBytesPath +from _typeshed import FileDescriptorLike, FloatInt, Incomplete, MaybeNone, StrOrBytesPath from collections.abc import Callable, Iterable, Mapping, Sequence from tkinter.constants import * from tkinter.font import _FontDescription @@ -167,8 +167,8 @@ __all__ = [ TclError = _tkinter.TclError wantobjects: int -TkVersion: Final[float] -TclVersion: Final[float] +TkVersion: Final[FloatInt] +TclVersion: Final[FloatInt] READABLE: Final = _tkinter.READABLE WRITABLE: Final = _tkinter.WRITABLE EXCEPTION: Final = _tkinter.EXCEPTION @@ -354,8 +354,8 @@ class IntVar(Variable): def get(self) -> int: ... class DoubleVar(Variable): - def __init__(self, master: Misc | None = None, value: float | None = None, name: str | None = None) -> None: ... - def set(self, value: float) -> None: ... + def __init__(self, master: Misc | None = None, value: FloatInt | None = None, name: str | None = None) -> None: ... + def set(self, value: FloatInt) -> None: ... initialize = set def get(self) -> float: ... @@ -377,8 +377,8 @@ _P = ParamSpec("_P") @type_check_only class _GridIndexInfo(TypedDict, total=False): - minsize: float | str - pad: float | str + minsize: FloatInt | str + pad: FloatInt | str uniform: str | None weight: int @@ -488,7 +488,7 @@ class Misc: def winfo_containing(self, rootX: int, rootY: int, displayof: Literal[0] | Misc | None = 0) -> Misc | None: ... def winfo_depth(self) -> int: ... def winfo_exists(self) -> bool: ... - def winfo_fpixels(self, number: float | str) -> float: ... + def winfo_fpixels(self, number: FloatInt | str) -> float: ... def winfo_geometry(self) -> str: ... def winfo_height(self) -> int: ... def winfo_id(self) -> int: ... @@ -498,7 +498,7 @@ class Misc: def winfo_name(self) -> str: ... def winfo_parent(self) -> str: ... # return value needs nametowidget() def winfo_pathname(self, id: int, displayof: Literal[0] | Misc | None = 0): ... - def winfo_pixels(self, number: float | str) -> int: ... + def winfo_pixels(self, number: FloatInt | str) -> int: ... def winfo_pointerx(self) -> int: ... def winfo_pointerxy(self) -> tuple[int, int]: ... def winfo_pointery(self) -> int: ... @@ -614,8 +614,8 @@ class Misc: index: int | str | list[int] | tuple[int, ...], cnf: _GridIndexInfo = {}, *, - minsize: float | str = ..., - pad: float | str = ..., + minsize: FloatInt | str = ..., + pad: FloatInt | str = ..., uniform: str = ..., weight: int = ..., ) -> _GridIndexInfo | MaybeNone: ... # can be None but annoying to check @@ -624,14 +624,14 @@ class Misc: index: int | str | list[int] | tuple[int, ...], cnf: _GridIndexInfo = {}, *, - minsize: float | str = ..., - pad: float | str = ..., + minsize: FloatInt | str = ..., + pad: FloatInt | str = ..., uniform: str = ..., weight: int = ..., ) -> _GridIndexInfo | MaybeNone: ... # can be None but annoying to check columnconfigure = grid_columnconfigure rowconfigure = grid_rowconfigure - def grid_location(self, x: float | str, y: float | str) -> tuple[int, int]: ... + def grid_location(self, x: FloatInt | str, y: FloatInt | str) -> tuple[int, int]: ... @overload def grid_propagate(self, flag: bool) -> None: ... @@ -658,32 +658,32 @@ class Misc: sequence: str, *, above: Misc | int = ..., - borderwidth: float | str = ..., + borderwidth: FloatInt | str = ..., button: int = ..., count: int = ..., data: Any = ..., # anything with usable str() value delta: int = ..., detail: str = ..., focus: bool = ..., - height: float | str = ..., + height: FloatInt | str = ..., keycode: int = ..., keysym: str = ..., mode: str = ..., override: bool = ..., place: Literal["PlaceOnTop", "PlaceOnBottom"] = ..., root: Misc | int = ..., - rootx: float | str = ..., - rooty: float | str = ..., + rootx: FloatInt | str = ..., + rooty: FloatInt | str = ..., sendevent: bool = ..., serial: int = ..., state: int | str = ..., subwindow: Misc | int = ..., time: int = ..., warp: bool = ..., - width: float | str = ..., + width: FloatInt | str = ..., when: Literal["now", "tail", "head", "mark"] = ..., - x: float | str = ..., - y: float | str = ..., + x: FloatInt | str = ..., + y: FloatInt | str = ..., ) -> None: ... def event_info(self, virtual: str | None = None) -> tuple[str, ...]: ... def image_names(self) -> tuple[str, ...]: ... @@ -708,12 +708,12 @@ class XView: @overload def xview(self, *args) -> None: ... - def xview_moveto(self, fraction: float) -> None: ... + def xview_moveto(self, fraction: FloatInt) -> None: ... @overload def xview_scroll(self, number: int, what: Literal["units", "pages"]) -> None: ... @overload - def xview_scroll(self, number: float | str, what: Literal["pixels"]) -> None: ... + def xview_scroll(self, number: FloatInt | str, what: Literal["pixels"]) -> None: ... class YView: @overload @@ -721,17 +721,17 @@ class YView: @overload def yview(self, *args) -> None: ... - def yview_moveto(self, fraction: float) -> None: ... + def yview_moveto(self, fraction: FloatInt) -> None: ... @overload def yview_scroll(self, number: int, what: Literal["units", "pages"]) -> None: ... @overload - def yview_scroll(self, number: float | str, what: Literal["pixels"]) -> None: ... + def yview_scroll(self, number: FloatInt | str, what: Literal["pixels"]) -> None: ... if sys.platform == "darwin": @type_check_only class _WmAttributes(TypedDict): - alpha: float + alpha: FloatInt fullscreen: bool modified: bool notify: bool @@ -743,7 +743,7 @@ if sys.platform == "darwin": elif sys.platform == "win32": @type_check_only class _WmAttributes(TypedDict): - alpha: float + alpha: FloatInt transparentcolor: str disabled: bool fullscreen: bool @@ -754,7 +754,7 @@ else: # X11 @type_check_only class _WmAttributes(TypedDict): - alpha: float + alpha: FloatInt topmost: bool zoomed: bool fullscreen: bool @@ -848,7 +848,7 @@ class Wm: @overload def wm_attributes(self, option: str, /): ... @overload - def wm_attributes(self, option: Literal["-alpha"], value: float, /) -> Literal[""]: ... + def wm_attributes(self, option: Literal["-alpha"], value: FloatInt, /) -> Literal[""]: ... @overload def wm_attributes(self, option: Literal["-fullscreen"], value: bool, /) -> Literal[""]: ... @overload @@ -887,7 +887,7 @@ class Wm: def wm_attributes( self, *, - alpha: float = ..., + alpha: FloatInt = ..., fullscreen: bool = ..., modified: bool = ..., notify: bool = ..., @@ -900,7 +900,7 @@ class Wm: def wm_attributes( self, *, - alpha: float = ..., + alpha: FloatInt = ..., transparentcolor: str = ..., disabled: bool = ..., fullscreen: bool = ..., @@ -911,7 +911,7 @@ class Wm: # X11 @overload def wm_attributes( - self, *, alpha: float = ..., topmost: bool = ..., zoomed: bool = ..., fullscreen: bool = ..., type: str = ... + self, *, alpha: FloatInt = ..., topmost: bool = ..., zoomed: bool = ..., fullscreen: bool = ..., type: str = ... ) -> None: ... attributes = wm_attributes @@ -1051,21 +1051,21 @@ class Tk(Misc, Wm): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., menu: Menu = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1152,10 +1152,10 @@ class Pack: expand: bool | Literal[0, 1] = 0, fill: Literal["none", "x", "y", "both"] = ..., side: Literal["left", "right", "top", "bottom"] = ..., - ipadx: float | str = ..., - ipady: float | str = ..., - padx: float | str | tuple[float | str, float | str] = ..., - pady: float | str | tuple[float | str, float | str] = ..., + ipadx: FloatInt | str = ..., + ipady: FloatInt | str = ..., + padx: FloatInt | str | tuple[FloatInt | str, FloatInt | str] = ..., + pady: FloatInt | str | tuple[FloatInt | str, FloatInt | str] = ..., in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... @@ -1185,15 +1185,15 @@ class Place: *, anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., bordermode: Literal["inside", "outside", "ignore"] = ..., - width: float | str = ..., - height: float | str = ..., - x: float | str = ..., - y: float | str = ..., + width: FloatInt | str = ..., + height: FloatInt | str = ..., + x: FloatInt | str = ..., + y: FloatInt | str = ..., # str allowed for compatibility with place_info() - relheight: str | float = ..., - relwidth: str | float = ..., - relx: str | float = ..., - rely: str | float = ..., + relheight: str | FloatInt = ..., + relwidth: str | FloatInt = ..., + relx: str | FloatInt = ..., + rely: str | FloatInt = ..., in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... @@ -1223,10 +1223,10 @@ class Grid: columnspan: int = ..., row: int = ..., rowspan: int = ..., - ipadx: float | str = ..., - ipady: float | str = ..., - padx: float | str | tuple[float | str, float | str] = ..., - pady: float | str | tuple[float | str, float | str] = ..., + ipadx: FloatInt | str = ..., + ipady: FloatInt | str = ..., + padx: FloatInt | str | tuple[FloatInt | str, FloatInt | str] = ..., + pady: FloatInt | str | tuple[FloatInt | str, FloatInt | str] = ..., sticky: ( str | list[str] | tuple[str, ...] ) = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty @@ -1273,28 +1273,28 @@ class Toplevel(BaseWidget, Wm): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = 0, + bd: FloatInt | str = 0, bg: str = ..., - border: float | str = 0, - borderwidth: float | str = 0, + border: FloatInt | str = 0, + borderwidth: FloatInt | str = 0, class_: str = "Toplevel", colormap: Literal["new", ""] | Misc = "", container: bool = False, cursor: _Cursor = "", - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, menu: Menu = ..., name: str = ..., - padx: float | str = 0, - pady: float | str = 0, + padx: FloatInt | str = 0, + pady: FloatInt | str = 0, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", screen: str = "", # can't be changed after creating widget takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, use: int = ..., visual: str | tuple[str, int] = "", - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -1303,21 +1303,21 @@ class Toplevel(BaseWidget, Wm): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., menu: Menu = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1334,11 +1334,11 @@ class Button(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = "center", background: str = ..., - bd: float | str = ..., # same as borderwidth + bd: FloatInt | str = ..., # same as borderwidth bg: str = ..., # same as background bitmap: str = "", - border: float | str = ..., # same as borderwidth - borderwidth: float | str = ..., + border: FloatInt | str = ..., # same as borderwidth + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = "", compound: Literal["top", "left", "center", "right", "bottom", "none"] = "none", cursor: _Cursor = "", @@ -1349,29 +1349,29 @@ class Button(Widget): foreground: str = ..., # width and height must be int for buttons containing just text, but # buttons with an image accept any screen units. - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 1, + highlightthickness: FloatInt | str = 1, image: _Image | str = "", justify: Literal["left", "center", "right"] = "center", name: str = ..., overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = "", - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., repeatdelay: int = ..., repeatinterval: int = ..., state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: FloatInt | str = "", # We allow the textvariable to be any Variable, not necessarily # StringVar. This is useful for e.g. a button that displays the value # of an IntVar. textvariable: Variable = ..., underline: int = -1, - width: float | str = 0, - wraplength: float | str = 0, + width: FloatInt | str = 0, + wraplength: FloatInt | str = 0, ) -> None: ... @overload @@ -1383,11 +1383,11 @@ class Button(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = ..., cursor: _Cursor = ..., @@ -1396,25 +1396,25 @@ class Button(Widget): fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., image: _Image | str = ..., justify: Literal["left", "center", "right"] = ..., overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., repeatdelay: int = ..., repeatinterval: int = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., underline: int = ..., - width: float | str = ..., - wraplength: float | str = ..., + width: FloatInt | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1430,39 +1430,39 @@ class Canvas(Widget, XView, YView): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = 0, + bd: FloatInt | str = 0, bg: str = ..., - border: float | str = 0, - borderwidth: float | str = 0, - closeenough: float = 1.0, + border: FloatInt | str = 0, + borderwidth: FloatInt | str = 0, + closeenough: FloatInt = 1.0, confine: bool = True, cursor: _Cursor = "", - height: float | str = ..., # see COORDINATES in canvas manual page + height: FloatInt | str = ..., # see COORDINATES in canvas manual page highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., insertbackground: str = ..., - insertborderwidth: float | str = 0, + insertborderwidth: FloatInt | str = 0, insertofftime: int = 300, insertontime: int = 600, - insertwidth: float | str = 2, + insertwidth: FloatInt | str = 2, name: str = ..., offset=..., # undocumented relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. - scrollregion: tuple[float | str, float | str, float | str, float | str] | tuple[()] = (), + scrollregion: tuple[FloatInt | str, FloatInt | str, FloatInt | str, FloatInt | str] | tuple[()] = (), selectbackground: str = ..., - selectborderwidth: float | str = 1, + selectborderwidth: FloatInt | str = 1, selectforeground: str = ..., # man page says that state can be 'hidden', but it can't state: Literal["normal", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - width: float | str = ..., - xscrollcommand: str | Callable[[float, float], object] = "", - xscrollincrement: float | str = 0, - yscrollcommand: str | Callable[[float, float], object] = "", - yscrollincrement: float | str = 0, + width: FloatInt | str = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", + xscrollincrement: FloatInt | str = 0, + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", + yscrollincrement: FloatInt | str = 0, ) -> None: ... @overload @@ -1471,35 +1471,35 @@ class Canvas(Widget, XView, YView): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., - closeenough: float = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., + closeenough: FloatInt = ..., confine: bool = ..., cursor: _Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., insertbackground: str = ..., - insertborderwidth: float | str = ..., + insertborderwidth: FloatInt | str = ..., insertofftime: int = ..., insertontime: int = ..., - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., offset=..., # undocumented relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., - scrollregion: tuple[float | str, float | str, float | str, float | str] | tuple[()] = ..., + scrollregion: tuple[FloatInt | str, FloatInt | str, FloatInt | str, FloatInt | str] | tuple[()] = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., state: Literal["normal", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - width: float | str = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., - xscrollincrement: float | str = ..., - yscrollcommand: str | Callable[[float, float], object] = ..., - yscrollincrement: float | str = ..., + width: FloatInt | str = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., + xscrollincrement: FloatInt | str = ..., + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., + yscrollincrement: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1510,20 +1510,31 @@ class Canvas(Widget, XView, YView): def addtag_all(self, newtag: str) -> None: ... def addtag_below(self, newtag: str, tagOrId: str | int) -> None: ... def addtag_closest( - self, newtag: str, x: float | str, y: float | str, halo: float | str | None = None, start: str | int | None = None + self, + newtag: str, + x: FloatInt | str, + y: FloatInt | str, + halo: FloatInt | str | None = None, + start: str | int | None = None, + ) -> None: ... + def addtag_enclosed( + self, newtag: str, x1: FloatInt | str, y1: FloatInt | str, x2: FloatInt | str, y2: FloatInt | str + ) -> None: ... + def addtag_overlapping( + self, newtag: str, x1: FloatInt | str, y1: FloatInt | str, x2: FloatInt | str, y2: FloatInt | str ) -> None: ... - def addtag_enclosed(self, newtag: str, x1: float | str, y1: float | str, x2: float | str, y2: float | str) -> None: ... - def addtag_overlapping(self, newtag: str, x1: float | str, y1: float | str, x2: float | str, y2: float | str) -> None: ... def addtag_withtag(self, newtag: str, tagOrId: str | int) -> None: ... def find(self, *args): ... # internal method def find_above(self, tagOrId: str | int) -> tuple[int, ...]: ... def find_all(self) -> tuple[int, ...]: ... def find_below(self, tagOrId: str | int) -> tuple[int, ...]: ... def find_closest( - self, x: float | str, y: float | str, halo: float | str | None = None, start: str | int | None = None + self, x: FloatInt | str, y: FloatInt | str, halo: FloatInt | str | None = None, start: str | int | None = None ) -> tuple[int, ...]: ... - def find_enclosed(self, x1: float | str, y1: float | str, x2: float | str, y2: float | str) -> tuple[int, ...]: ... - def find_overlapping(self, x1: float | str, y1: float | str, x2: float | str, y2: float) -> tuple[int, ...]: ... + def find_enclosed( + self, x1: FloatInt | str, y1: FloatInt | str, x2: FloatInt | str, y2: FloatInt | str + ) -> tuple[int, ...]: ... + def find_overlapping(self, x1: FloatInt | str, y1: FloatInt | str, x2: FloatInt | str, y2: FloatInt) -> tuple[int, ...]: ... def find_withtag(self, tagOrId: str | int) -> tuple[int, ...]: ... # Incompatible with Misc.bbox(), tkinter violates LSP def bbox(self, *args: str | int) -> tuple[int, int, int, int]: ... # type: ignore[override] @@ -1544,15 +1555,15 @@ class Canvas(Widget, XView, YView): def tag_bind(self, tagOrId: str | int, *, func: str, add: Literal["", "+"] | bool | None = None) -> None: ... def tag_unbind(self, tagOrId: str | int, sequence: str, funcid: str | None = None) -> None: ... - def canvasx(self, screenx: float | str, gridspacing: float | str | None = None) -> float: ... - def canvasy(self, screeny: float | str, gridspacing: float | str | None = None) -> float: ... + def canvasx(self, screenx: FloatInt | str, gridspacing: FloatInt | str | None = None) -> float: ... + def canvasy(self, screeny: FloatInt | str, gridspacing: FloatInt | str | None = None) -> float: ... @overload def coords(self, tagOrId: str | int, /) -> list[float]: ... @overload - def coords(self, tagOrId: str | int, args: list[int] | list[float] | tuple[float, ...], /) -> None: ... + def coords(self, tagOrId: str | int, args: list[int] | list[FloatInt] | tuple[FloatInt, ...], /) -> None: ... @overload - def coords(self, tagOrId: str | int, x1: float, y1: float, /, *args: float) -> None: ... + def coords(self, tagOrId: str | int, x1: FloatInt, y1: FloatInt, /, *args: FloatInt) -> None: ... # create_foo() methods accept coords as a list or tuple, or as separate arguments. # Lists and tuples can be flat as in [1, 2, 3, 4], or nested as in [(1, 2), (3, 4)]. @@ -1564,109 +1575,109 @@ class Canvas(Widget, XView, YView): @overload def create_line( self, - x0: float, - y0: float, - x1: float, - y1: float, + x0: FloatInt, + y0: FloatInt, + x1: FloatInt, + y1: FloatInt, /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., activefill: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., arrow: Literal["first", "last", "both"] = ..., - arrowshape: tuple[float, float, float] = ..., + arrowshape: tuple[FloatInt, FloatInt, FloatInt] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_line( self, - xy_pair_0: tuple[float, float], - xy_pair_1: tuple[float, float], + xy_pair_0: tuple[FloatInt, FloatInt], + xy_pair_1: tuple[FloatInt, FloatInt], /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., activefill: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., arrow: Literal["first", "last", "both"] = ..., - arrowshape: tuple[float, float, float] = ..., + arrowshape: tuple[FloatInt, FloatInt, FloatInt] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_line( self, coords: ( - tuple[float, float, float, float] - | tuple[tuple[float, float], tuple[float, float]] + tuple[FloatInt, FloatInt, FloatInt, FloatInt] + | tuple[tuple[FloatInt, FloatInt], tuple[FloatInt, FloatInt]] | list[int] - | list[float] + | list[FloatInt] | list[tuple[int, int]] - | list[tuple[float, float]] + | list[tuple[FloatInt, FloatInt]] ), /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., activefill: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., arrow: Literal["first", "last", "both"] = ..., - arrowshape: tuple[float, float, float] = ..., + arrowshape: tuple[FloatInt, FloatInt, FloatInt] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_oval( self, - x0: float, - y0: float, - x1: float, - y1: float, + x0: FloatInt, + y0: FloatInt, + x1: FloatInt, + y1: FloatInt, /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., @@ -1674,30 +1685,30 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_oval( self, - xy_pair_0: tuple[float, float], - xy_pair_1: tuple[float, float], + xy_pair_0: tuple[FloatInt, FloatInt], + xy_pair_1: tuple[FloatInt, FloatInt], /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., @@ -1705,35 +1716,35 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_oval( self, coords: ( - tuple[float, float, float, float] - | tuple[tuple[float, float], tuple[float, float]] + tuple[FloatInt, FloatInt, FloatInt, FloatInt] + | tuple[tuple[FloatInt, FloatInt], tuple[FloatInt, FloatInt]] | list[int] - | list[float] + | list[FloatInt] | list[tuple[int, int]] - | list[tuple[float, float]] + | list[tuple[FloatInt, FloatInt]] ), /, *, @@ -1742,106 +1753,106 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_polygon( self, - x0: float, - y0: float, - x1: float, - y1: float, + x0: FloatInt, + y0: FloatInt, + x1: FloatInt, + y1: FloatInt, /, - *xy_pairs: float, + *xy_pairs: FloatInt, activedash: str | int | list[int] | tuple[int, ...] = ..., activefill: str = ..., activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_polygon( self, - xy_pair_0: tuple[float, float], - xy_pair_1: tuple[float, float], + xy_pair_0: tuple[FloatInt, FloatInt], + xy_pair_1: tuple[FloatInt, FloatInt], /, - *xy_pairs: tuple[float, float], + *xy_pairs: tuple[FloatInt, FloatInt], activedash: str | int | list[int] | tuple[int, ...] = ..., activefill: str = ..., activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_polygon( self, coords: ( - tuple[float, ...] - | tuple[tuple[float, float], ...] + tuple[FloatInt, ...] + | tuple[tuple[FloatInt, FloatInt], ...] | list[int] - | list[float] + | list[FloatInt] | list[tuple[int, int]] - | list[tuple[float, float]] + | list[tuple[FloatInt, FloatInt]] ), /, *, @@ -1850,36 +1861,36 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., joinstyle: Literal["round", "bevel", "miter"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., smooth: bool = ..., - splinesteps: float = ..., + splinesteps: FloatInt = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_rectangle( self, - x0: float, - y0: float, - x1: float, - y1: float, + x0: FloatInt, + y0: FloatInt, + x1: FloatInt, + y1: FloatInt, /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., @@ -1887,30 +1898,30 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_rectangle( self, - xy_pair_0: tuple[float, float], - xy_pair_1: tuple[float, float], + xy_pair_0: tuple[FloatInt, FloatInt], + xy_pair_1: tuple[FloatInt, FloatInt], /, *, activedash: str | int | list[int] | tuple[int, ...] = ..., @@ -1918,35 +1929,35 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_rectangle( self, coords: ( - tuple[float, float, float, float] - | tuple[tuple[float, float], tuple[float, float]] + tuple[FloatInt, FloatInt, FloatInt, FloatInt] + | tuple[tuple[FloatInt, FloatInt], tuple[FloatInt, FloatInt]] | list[int] - | list[float] + | list[FloatInt] | list[tuple[int, int]] - | list[tuple[float, float]] + | list[tuple[FloatInt, FloatInt]] ), /, *, @@ -1955,97 +1966,97 @@ class Canvas(Widget, XView, YView): activeoutline: str = ..., activeoutlinestipple: str = ..., activestipple: str = ..., - activewidth: float | str = ..., + activewidth: FloatInt | str = ..., dash: str | int | list[int] | tuple[int, ...] = ..., - dashoffset: float | str = ..., + dashoffset: FloatInt | str = ..., disableddash: str | int | list[int] | tuple[int, ...] = ..., disabledfill: str = ..., disabledoutline: str = ..., disabledoutlinestipple: str = ..., disabledstipple: str = ..., - disabledwidth: float | str = ..., + disabledwidth: FloatInt | str = ..., fill: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., outline: str = ..., - outlineoffset: float | str = ..., + outlineoffset: FloatInt | str = ..., outlinestipple: str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_text( self, - x: float, - y: float, + x: FloatInt, + y: FloatInt, /, *, activefill: str = ..., activestipple: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., - angle: float | str = ..., + angle: FloatInt | str = ..., disabledfill: str = ..., disabledstipple: str = ..., fill: str = ..., font: _FontDescription = ..., justify: Literal["left", "center", "right"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - text: float | str = ..., - width: float | str = ..., + text: FloatInt | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_text( self, - coords: tuple[float, float] | list[int] | list[float], + coords: tuple[FloatInt, FloatInt] | list[int] | list[FloatInt], /, *, activefill: str = ..., activestipple: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., - angle: float | str = ..., + angle: FloatInt | str = ..., disabledfill: str = ..., disabledstipple: str = ..., fill: str = ..., font: _FontDescription = ..., justify: Literal["left", "center", "right"] = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., state: Literal["normal", "hidden", "disabled"] = ..., stipple: str = ..., tags: str | list[str] | tuple[str, ...] = ..., - text: float | str = ..., - width: float | str = ..., + text: FloatInt | str = ..., + width: FloatInt | str = ..., ) -> int: ... @overload def create_window( self, - x: float, - y: float, + x: FloatInt, + y: FloatInt, /, *, anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., - height: float | str = ..., + height: FloatInt | str = ..., state: Literal["normal", "hidden", "disabled"] = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., window: Widget = ..., ) -> int: ... @overload def create_window( self, - coords: tuple[float, float] | list[int] | list[float], + coords: tuple[FloatInt, FloatInt] | list[int] | list[FloatInt], /, *, anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., - height: float | str = ..., + height: FloatInt | str = ..., state: Literal["normal", "hidden", "disabled"] = ..., tags: str | list[str] | tuple[str, ...] = ..., - width: float | str = ..., + width: FloatInt | str = ..., window: Widget = ..., ) -> int: ... @@ -2069,7 +2080,7 @@ class Canvas(Widget, XView, YView): ) -> dict[str, tuple[str, str, str, str, str]] | None: ... itemconfig = itemconfigure def move(self, *args) -> None: ... - def moveto(self, tagOrId: str | int, x: Literal[""] | float = "", y: Literal[""] | float = "") -> None: ... + def moveto(self, tagOrId: str | int, x: Literal[""] | FloatInt = "", y: Literal[""] | FloatInt = "") -> None: ... def postscript(self, cnf={}, **kw): ... # tkinter does: # lower = tag_lower @@ -2081,7 +2092,9 @@ class Canvas(Widget, XView, YView): def tag_raise(self, first: str | int, second: str | int | None = ..., /) -> None: ... def tkraise(self, first: str | int, second: str | int | None = ..., /) -> None: ... # type: ignore[override] def lift(self, first: str | int, second: str | int | None = ..., /) -> None: ... # type: ignore[override] - def scale(self, tagOrId: str | int, xOrigin: float | str, yOrigin: float | str, xScale: float, yScale: float, /) -> None: ... + def scale( + self, tagOrId: str | int, xOrigin: FloatInt | str, yOrigin: FloatInt | str, xScale: FloatInt, yScale: FloatInt, / + ) -> None: ... def scan_mark(self, x, y) -> None: ... def scan_dragto(self, x, y, gain: int = 10) -> None: ... def select_adjust(self, tagOrId, index) -> None: ... @@ -2101,11 +2114,11 @@ class Checkbutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = "center", background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = "", - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = "", compound: Literal["top", "left", "center", "right", "bottom", "none"] = "none", cursor: _Cursor = "", @@ -2113,10 +2126,10 @@ class Checkbutton(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 1, + highlightthickness: FloatInt | str = 1, image: _Image | str = "", indicatoron: bool = True, justify: Literal["left", "center", "right"] = "center", @@ -2135,21 +2148,21 @@ class Checkbutton(Widget): offvalue: Any = 0, onvalue: Any = 1, overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = "", - padx: float | str = 1, - pady: float | str = 1, + padx: FloatInt | str = 1, + pady: FloatInt | str = 1, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", selectcolor: str = ..., selectimage: _Image | str = "", state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: FloatInt | str = "", textvariable: Variable = ..., tristateimage: _Image | str = "", tristatevalue: Any = "", underline: int = -1, variable: Variable | Literal[""] = ..., - width: float | str = 0, - wraplength: float | str = 0, + width: FloatInt | str = 0, + wraplength: FloatInt | str = 0, ) -> None: ... @overload @@ -2161,11 +2174,11 @@ class Checkbutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = ..., cursor: _Cursor = ..., @@ -2173,10 +2186,10 @@ class Checkbutton(Widget): fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., image: _Image | str = ..., indicatoron: bool = ..., justify: Literal["left", "center", "right"] = ..., @@ -2184,21 +2197,21 @@ class Checkbutton(Widget): offvalue: Any = ..., onvalue: Any = ..., overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectcolor: str = ..., selectimage: _Image | str = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., tristateimage: _Image | str = ..., tristatevalue: Any = ..., underline: int = ..., variable: Variable | Literal[""] = ..., - width: float | str = ..., - wraplength: float | str = ..., + width: FloatInt | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2217,10 +2230,10 @@ class Entry(Widget, XView): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = "xterm", disabledbackground: str = ..., disabledforeground: str = ..., @@ -2230,12 +2243,12 @@ class Entry(Widget, XView): foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., insertbackground: str = ..., - insertborderwidth: float | str = 0, + insertborderwidth: FloatInt | str = 0, insertofftime: int = 300, insertontime: int = 600, - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = "", invcmd: str | list[str] | tuple[str, ...] | Callable[[], object] = "", # same as invalidcommand justify: Literal["left", "center", "right"] = "left", @@ -2243,7 +2256,7 @@ class Entry(Widget, XView): readonlybackground: str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "sunken", selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., show: str = "", state: Literal["normal", "disabled", "readonly"] = "normal", @@ -2253,7 +2266,7 @@ class Entry(Widget, XView): validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", vcmd: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", # same as validatecommand width: int = 20, - xscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload @@ -2262,10 +2275,10 @@ class Entry(Widget, XView): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., disabledbackground: str = ..., disabledforeground: str = ..., @@ -2275,19 +2288,19 @@ class Entry(Widget, XView): foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., insertbackground: str = ..., - insertborderwidth: float | str = ..., + insertborderwidth: FloatInt | str = ..., insertofftime: int = ..., insertontime: int = ..., - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., invcmd: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., justify: Literal["left", "center", "right"] = ..., readonlybackground: str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., show: str = ..., state: Literal["normal", "disabled", "readonly"] = ..., @@ -2297,7 +2310,7 @@ class Entry(Widget, XView): validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., vcmd: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2330,25 +2343,25 @@ class Frame(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = 0, + bd: FloatInt | str = 0, bg: str = ..., - border: float | str = 0, - borderwidth: float | str = 0, + border: FloatInt | str = 0, + borderwidth: FloatInt | str = 0, class_: str = "Frame", # can't be changed with configure() colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() container: bool = False, # can't be changed with configure() cursor: _Cursor = "", - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, name: str = ..., - padx: float | str = 0, - pady: float | str = 0, + padx: FloatInt | str = 0, + pady: FloatInt | str = 0, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, visual: str | tuple[str, int] = "", # can't be changed with configure() - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -2357,20 +2370,20 @@ class Frame(Widget): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., - padx: float | str = ..., - pady: float | str = ..., + highlightthickness: FloatInt | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2387,34 +2400,34 @@ class Label(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = "center", background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = "", - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = "none", cursor: _Cursor = "", disabledforeground: str = ..., fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, image: _Image | str = "", justify: Literal["left", "center", "right"] = "center", name: str = ..., - padx: float | str = 1, - pady: float | str = 1, + padx: FloatInt | str = 1, + pady: FloatInt | str = 1, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, - text: float | str = "", + text: FloatInt | str = "", textvariable: Variable = ..., underline: int = -1, - width: float | str = 0, - wraplength: float | str = 0, + width: FloatInt | str = 0, + wraplength: FloatInt | str = 0, ) -> None: ... @overload @@ -2426,33 +2439,33 @@ class Label(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = ..., cursor: _Cursor = ..., disabledforeground: str = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., image: _Image | str = ..., justify: Literal["left", "center", "right"] = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., underline: int = ..., - width: float | str = ..., - wraplength: float | str = ..., + width: FloatInt | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2467,10 +2480,10 @@ class Listbox(Widget, XView, YView): *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: str = ..., - bd: float | str = 1, + bd: FloatInt | str = 1, bg: str = ..., - border: float | str = 1, - borderwidth: float | str = 1, + border: FloatInt | str = 1, + borderwidth: FloatInt | str = 1, cursor: _Cursor = "", disabledforeground: str = ..., exportselection: bool | Literal[0, 1] = 1, @@ -2480,7 +2493,7 @@ class Listbox(Widget, XView, YView): height: int = 10, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., justify: Literal["left", "center", "right"] = "left", # There's no tkinter.ListVar, but seems like bare tkinter.Variable # actually works for this: @@ -2495,7 +2508,7 @@ class Listbox(Widget, XView, YView): name: str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectbackground: str = ..., - selectborderwidth: float | str = 0, + selectborderwidth: FloatInt | str = 0, selectforeground: str = ..., # from listbox man page: "The value of the [selectmode] option may be # arbitrary, but the default bindings expect it to be either single, @@ -2508,8 +2521,8 @@ class Listbox(Widget, XView, YView): state: Literal["normal", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", width: int = 20, - xscrollcommand: str | Callable[[float, float], object] = "", - yscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload @@ -2519,10 +2532,10 @@ class Listbox(Widget, XView, YView): *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., disabledforeground: str = ..., exportselection: bool = ..., @@ -2532,20 +2545,20 @@ class Listbox(Widget, XView, YView): height: int = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., justify: Literal["left", "center", "right"] = ..., listvariable: Variable = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., selectmode: str | Literal["single", "browse", "multiple", "extended"] = ..., # noqa: Y051 setgrid: bool = ..., state: Literal["normal", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., - yscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2557,7 +2570,7 @@ class Listbox(Widget, XView, YView): def delete(self, first: str | int, last: str | int | None = None) -> None: ... def get(self, first: str | int, last: str | int | None = None): ... def index(self, index: str | int) -> int: ... - def insert(self, index: str | int, *elements: str | float) -> None: ... + def insert(self, index: str | int, *elements: str | FloatInt) -> None: ... def nearest(self, y): ... def scan_mark(self, x, y) -> None: ... def scan_dragto(self, x, y) -> None: ... @@ -2582,13 +2595,13 @@ class Menu(Widget): cnf: dict[str, Any] | None = {}, *, activebackground: str = ..., - activeborderwidth: float | str = ..., + activeborderwidth: FloatInt | str = ..., activeforeground: str = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = "arrow", disabledforeground: str = ..., fg: str = ..., @@ -2614,13 +2627,13 @@ class Menu(Widget): cnf: dict[str, Any] | None = None, *, activebackground: str = ..., - activeborderwidth: float | str = ..., + activeborderwidth: FloatInt | str = ..., activeforeground: str = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., disabledforeground: str = ..., fg: str = ..., @@ -2857,11 +2870,11 @@ class Menubutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = "", - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = "none", cursor: _Cursor = "", direction: Literal["above", "below", "left", "right", "flush"] = "below", @@ -2869,25 +2882,25 @@ class Menubutton(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, image: _Image | str = "", indicatoron: bool = ..., justify: Literal["left", "center", "right"] = ..., menu: Menu = ..., name: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, - text: float | str = "", + text: FloatInt | str = "", textvariable: Variable = ..., underline: int = -1, - width: float | str = 0, - wraplength: float | str = 0, + width: FloatInt | str = 0, + wraplength: FloatInt | str = 0, ) -> None: ... @overload @@ -2899,11 +2912,11 @@ class Menubutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = ..., cursor: _Cursor = ..., direction: Literal["above", "below", "left", "right", "flush"] = ..., @@ -2911,24 +2924,24 @@ class Menubutton(Widget): fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., image: _Image | str = ..., indicatoron: bool = ..., justify: Literal["left", "center", "right"] = ..., menu: Menu = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., underline: int = ..., - width: float | str = ..., - wraplength: float | str = ..., + width: FloatInt | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -2944,27 +2957,27 @@ class Message(Widget): anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = "center", aspect: int = 150, background: str = ..., - bd: float | str = 1, + bd: FloatInt | str = 1, bg: str = ..., - border: float | str = 1, - borderwidth: float | str = 1, + border: FloatInt | str = 1, + borderwidth: FloatInt | str = 1, cursor: _Cursor = "", fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, justify: Literal["left", "center", "right"] = "left", name: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, - text: float | str = "", + text: FloatInt | str = "", textvariable: Variable = ..., # there's width but no height - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -2975,25 +2988,25 @@ class Message(Widget): anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., aspect: int = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., justify: Literal["left", "center", "right"] = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -3010,11 +3023,11 @@ class Radiobutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = "center", background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = "", - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = "", compound: Literal["top", "left", "center", "right", "bottom", "none"] = "none", cursor: _Cursor = "", @@ -3022,32 +3035,32 @@ class Radiobutton(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 1, + highlightthickness: FloatInt | str = 1, image: _Image | str = "", indicatoron: bool = True, justify: Literal["left", "center", "right"] = "center", name: str = ..., offrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = "", - padx: float | str = 1, - pady: float | str = 1, + padx: FloatInt | str = 1, + pady: FloatInt | str = 1, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", selectcolor: str = ..., selectimage: _Image | str = "", state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: FloatInt | str = "", textvariable: Variable = ..., tristateimage: _Image | str = "", tristatevalue: Any = "", underline: int = -1, value: Any = "", variable: Variable | Literal[""] = ..., - width: float | str = 0, - wraplength: float | str = 0, + width: FloatInt | str = 0, + wraplength: FloatInt | str = 0, ) -> None: ... @overload @@ -3059,11 +3072,11 @@ class Radiobutton(Widget): activeforeground: str = ..., anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., bitmap: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[], Any] = ..., compound: Literal["top", "left", "center", "right", "bottom", "none"] = ..., cursor: _Cursor = ..., @@ -3071,31 +3084,31 @@ class Radiobutton(Widget): fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., image: _Image | str = ..., indicatoron: bool = ..., justify: Literal["left", "center", "right"] = ..., offrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., overrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove", ""] = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectcolor: str = ..., selectimage: _Image | str = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: Variable = ..., tristateimage: _Image | str = ..., tristatevalue: Any = ..., underline: int = ..., value: Any = ..., variable: Variable | Literal[""] = ..., - width: float | str = ..., - wraplength: float | str = ..., + width: FloatInt | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -3114,11 +3127,11 @@ class Scale(Widget): *, activebackground: str = ..., background: str = ..., - bd: float | str = 1, + bd: FloatInt | str = 1, bg: str = ..., - bigincrement: float = 0.0, - border: float | str = 1, - borderwidth: float | str = 1, + bigincrement: FloatInt = 0.0, + border: FloatInt | str = 1, + borderwidth: FloatInt | str = 1, # don't know why the callback gets string instead of float command: str | Callable[[str], object] = "", cursor: _Cursor = "", @@ -3126,28 +3139,28 @@ class Scale(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - from_: float = 0.0, + from_: FloatInt = 0.0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., label: str = "", - length: float | str = 100, + length: FloatInt | str = 100, name: str = ..., orient: Literal["horizontal", "vertical"] = "vertical", relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", repeatdelay: int = 300, repeatinterval: int = 100, - resolution: float = 1.0, + resolution: FloatInt = 1.0, showvalue: bool = True, - sliderlength: float | str = 30, + sliderlength: FloatInt | str = 30, sliderrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "raised", state: Literal["normal", "active", "disabled"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - tickinterval: float = 0.0, - to: float = 100.0, + tickinterval: FloatInt = 0.0, + to: FloatInt = 100.0, troughcolor: str = ..., variable: IntVar | DoubleVar = ..., - width: float | str = 15, + width: FloatInt | str = 15, ) -> None: ... @overload @@ -3157,38 +3170,38 @@ class Scale(Widget): *, activebackground: str = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - bigincrement: float = ..., - border: float | str = ..., - borderwidth: float | str = ..., + bigincrement: FloatInt = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: str | Callable[[str], object] = ..., cursor: _Cursor = ..., digits: int = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - from_: float = ..., + from_: FloatInt = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., label: str = ..., - length: float | str = ..., + length: FloatInt | str = ..., orient: Literal["horizontal", "vertical"] = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., repeatdelay: int = ..., repeatinterval: int = ..., - resolution: float = ..., + resolution: FloatInt = ..., showvalue: bool = ..., - sliderlength: float | str = ..., + sliderlength: FloatInt | str = ..., sliderrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - tickinterval: float = ..., - to: float = ..., + tickinterval: FloatInt = ..., + to: FloatInt = ..., troughcolor: str = ..., variable: IntVar | DoubleVar = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -3196,7 +3209,7 @@ class Scale(Widget): config = configure def get(self) -> float: ... def set(self, value) -> None: ... - def coords(self, value: float | None = None) -> tuple[int, int]: ... + def coords(self, value: FloatInt | None = None) -> tuple[int, int]: ... def identify(self, x, y) -> Literal["", "slider", "trough1", "trough2"]: ... class Scrollbar(Widget): @@ -3208,20 +3221,20 @@ class Scrollbar(Widget): activebackground: str = ..., activerelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "raised", background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., # There are many ways how the command may get called. Search for # 'SCROLLING COMMANDS' in scrollbar man page. There doesn't seem to # be any way to specify an overloaded callback function, so we say # that it can take any args while it can't in reality. command: Callable[..., tuple[float, float] | None] | str = "", cursor: _Cursor = "", - elementborderwidth: float | str = -1, + elementborderwidth: FloatInt | str = -1, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, jump: bool = False, name: str = ..., orient: Literal["horizontal", "vertical"] = "vertical", @@ -3230,7 +3243,7 @@ class Scrollbar(Widget): repeatinterval: int = 100, takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", troughcolor: str = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> None: ... @overload @@ -3241,16 +3254,16 @@ class Scrollbar(Widget): activebackground: str = ..., activerelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., command: Callable[..., tuple[float, float] | None] | str = ..., cursor: _Cursor = ..., - elementborderwidth: float | str = ..., + elementborderwidth: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., jump: bool = ..., orient: Literal["horizontal", "vertical"] = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., @@ -3258,7 +3271,7 @@ class Scrollbar(Widget): repeatinterval: int = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., troughcolor: str = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -3269,7 +3282,7 @@ class Scrollbar(Widget): def fraction(self, x: int, y: int) -> float: ... def identify(self, x: int, y: int) -> Literal["arrow1", "arrow2", "slider", "trough1", "trough2", ""]: ... def get(self) -> tuple[float, float, float, float] | tuple[float, float]: ... - def set(self, first: float | str, last: float | str) -> None: ... + def set(self, first: FloatInt | str, last: FloatInt | str) -> None: ... _WhatToCount: TypeAlias = Literal[ "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels", "ypixels" @@ -3283,11 +3296,11 @@ class Text(Widget, XView, YView): *, autoseparators: bool = True, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., blockcursor: bool = False, - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = "xterm", endline: int | Literal[""] = "", exportselection: bool = True, @@ -3297,40 +3310,40 @@ class Text(Widget, XView, YView): # width is always int, but height is allowed to be screen units. # This doesn't make any sense to me, and this isn't documented. # The docs seem to say that both should be integers. - height: float | str = 24, + height: FloatInt | str = 24, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., inactiveselectbackground: str = ..., insertbackground: str = ..., - insertborderwidth: float | str = 0, + insertborderwidth: FloatInt | str = 0, insertofftime: int = 300, insertontime: int = 600, insertunfocussed: Literal["none", "hollow", "solid"] = "none", - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., maxundo: int = 0, name: str = ..., - padx: float | str = 1, - pady: float | str = 1, + padx: FloatInt | str = 1, + pady: FloatInt | str = 1, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., setgrid: bool = False, - spacing1: float | str = 0, - spacing2: float | str = 0, - spacing3: float | str = 0, + spacing1: FloatInt | str = 0, + spacing2: FloatInt | str = 0, + spacing3: FloatInt | str = 0, startline: int | Literal[""] = "", state: Literal["normal", "disabled"] = "normal", # Literal inside Tuple doesn't actually work - tabs: float | str | tuple[float | str, ...] = "", + tabs: FloatInt | str | tuple[FloatInt | str, ...] = "", tabstyle: Literal["tabular", "wordprocessor"] = "tabular", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", undo: bool = False, width: int = 80, wrap: Literal["none", "char", "word"] = "char", - xscrollcommand: str | Callable[[float, float], object] = "", - yscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload @@ -3340,76 +3353,76 @@ class Text(Widget, XView, YView): *, autoseparators: bool = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., blockcursor: bool = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., endline: int | Literal[""] = ..., exportselection: bool = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., inactiveselectbackground: str = ..., insertbackground: str = ..., - insertborderwidth: float | str = ..., + insertborderwidth: FloatInt | str = ..., insertofftime: int = ..., insertontime: int = ..., insertunfocussed: Literal["none", "hollow", "solid"] = ..., - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., maxundo: int = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., setgrid: bool = ..., - spacing1: float | str = ..., - spacing2: float | str = ..., - spacing3: float | str = ..., + spacing1: FloatInt | str = ..., + spacing2: FloatInt | str = ..., + spacing3: FloatInt | str = ..., startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: float | str | tuple[float | str, ...] = ..., + tabs: FloatInt | str | tuple[FloatInt | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., undo: bool = ..., width: int = ..., wrap: Literal["none", "char", "word"] = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., - yscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure - def bbox(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> tuple[int, int, int, int] | None: ... # type: ignore[override] + def bbox(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> tuple[int, int, int, int] | None: ... # type: ignore[override] def compare( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, op: Literal["<", "<=", "==", ">=", ">", "!="], - index2: str | float | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, ) -> bool: ... if sys.version_info >= (3, 13): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, *, return_ints: Literal[True], ) -> int: ... @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg: _WhatToCount | Literal["update"], /, *, @@ -3418,8 +3431,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: Literal["update"], arg2: _WhatToCount, /, @@ -3429,8 +3442,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: Literal["update"], /, @@ -3440,8 +3453,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: _WhatToCount, /, @@ -3451,8 +3464,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount | Literal["update"], arg2: _WhatToCount | Literal["update"], arg3: _WhatToCount | Literal["update"], @@ -3463,16 +3476,16 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, *, return_ints: Literal[False] = False, ) -> tuple[int] | None: ... @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg: _WhatToCount | Literal["update"], /, *, @@ -3481,8 +3494,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: Literal["update"], arg2: _WhatToCount, /, @@ -3492,8 +3505,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: Literal["update"], /, @@ -3503,8 +3516,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: _WhatToCount, /, @@ -3514,8 +3527,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount | Literal["update"], arg2: _WhatToCount | Literal["update"], arg3: _WhatToCount | Literal["update"], @@ -3526,21 +3539,21 @@ class Text(Widget, XView, YView): else: @overload def count( - self, index1: str | float | _tkinter.Tcl_Obj | Widget, index2: str | float | _tkinter.Tcl_Obj | Widget + self, index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, index2: str | FloatInt | _tkinter.Tcl_Obj | Widget ) -> tuple[int] | None: ... @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg: _WhatToCount | Literal["update"], /, ) -> tuple[int] | None: ... @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: Literal["update"], arg2: _WhatToCount, /, @@ -3548,8 +3561,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: Literal["update"], /, @@ -3557,8 +3570,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount, arg2: _WhatToCount, /, @@ -3566,8 +3579,8 @@ class Text(Widget, XView, YView): @overload def count( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, arg1: _WhatToCount | Literal["update"], arg2: _WhatToCount | Literal["update"], arg3: _WhatToCount | Literal["update"], @@ -3581,15 +3594,15 @@ class Text(Widget, XView, YView): def debug(self, boolean: bool) -> None: ... def delete( - self, index1: str | float | _tkinter.Tcl_Obj | Widget, index2: str | float | _tkinter.Tcl_Obj | Widget | None = None + self, index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None ) -> None: ... - def dlineinfo(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> tuple[int, int, int, int, int] | None: ... + def dlineinfo(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> tuple[int, int, int, int, int] | None: ... @overload def dump( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, command: None = None, *, all: bool = ..., @@ -3602,8 +3615,8 @@ class Text(Widget, XView, YView): @overload def dump( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None, command: Callable[[str, str, str], object] | str, *, all: bool = ..., @@ -3616,8 +3629,8 @@ class Text(Widget, XView, YView): @overload def dump( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, *, command: Callable[[str, str, str], object] | str, all: bool = ..., @@ -3640,52 +3653,52 @@ class Text(Widget, XView, YView): def edit_separator(self) -> None: ... # actually returns empty string def edit_undo(self) -> None: ... # actually returns empty string def get( - self, index1: str | float | _tkinter.Tcl_Obj | Widget, index2: str | float | _tkinter.Tcl_Obj | Widget | None = None + self, index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None ) -> str: ... @overload - def image_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["image", "name"]) -> str: ... + def image_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["image", "name"]) -> str: ... @overload - def image_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["padx", "pady"]) -> int: ... + def image_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["padx", "pady"]) -> int: ... @overload def image_cget( - self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["align"] + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["align"] ) -> Literal["baseline", "bottom", "center", "top"]: ... @overload - def image_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: str) -> Any: ... + def image_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: str) -> Any: ... @overload def image_configure( - self, index: str | float | _tkinter.Tcl_Obj | Widget, cnf: str + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: str ) -> tuple[str, str, str, str, str | int]: ... @overload def image_configure( self, - index: str | float | _tkinter.Tcl_Obj | Widget, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: dict[str, Any] | None = None, *, align: Literal["baseline", "bottom", "center", "top"] = ..., image: _Image | str = ..., name: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, str, str | int]] | None: ... def image_create( self, - index: str | float | _tkinter.Tcl_Obj | Widget, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: dict[str, Any] | None = {}, *, align: Literal["baseline", "bottom", "center", "top"] = ..., image: _Image | str = ..., name: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., ) -> str: ... def image_names(self) -> tuple[str, ...]: ... - def index(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> str: ... + def index(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> str: ... def insert( - self, index: str | float | _tkinter.Tcl_Obj | Widget, chars: str, *args: str | list[str] | tuple[str, ...] + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, chars: str, *args: str | list[str] | tuple[str, ...] ) -> None: ... @overload @@ -3694,17 +3707,17 @@ class Text(Widget, XView, YView): def mark_gravity(self, markName: str, direction: Literal["left", "right"]) -> None: ... # actually returns empty string def mark_names(self) -> tuple[str, ...]: ... - def mark_set(self, markName: str, index: str | float | _tkinter.Tcl_Obj | Widget) -> None: ... + def mark_set(self, markName: str, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> None: ... def mark_unset(self, *markNames: str) -> None: ... - def mark_next(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> str | None: ... - def mark_previous(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> str | None: ... + def mark_next(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> str | None: ... + def mark_previous(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = {}, **kw) -> None: ... def peer_names(self) -> tuple[_tkinter.Tcl_Obj, ...]: ... def replace( self, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget, chars: str, *args: str | list[str] | tuple[str, ...], ) -> None: ... @@ -3714,8 +3727,8 @@ class Text(Widget, XView, YView): def search( self, pattern: str, - index: str | float | _tkinter.Tcl_Obj | Widget, - stopindex: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, + stopindex: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, forwards: bool | None = None, backwards: bool | None = None, exact: bool | None = None, @@ -3730,8 +3743,8 @@ class Text(Widget, XView, YView): def search_all( self, pattern: str, - index: str | float | _tkinter.Tcl_Obj | Widget, - stopindex: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, + stopindex: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, *, forwards: bool | None = None, backwards: bool | None = None, @@ -3748,8 +3761,8 @@ class Text(Widget, XView, YView): def search( self, pattern: str, - index: str | float | _tkinter.Tcl_Obj | Widget, - stopindex: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, + stopindex: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, forwards: bool | None = None, backwards: bool | None = None, exact: bool | None = None, @@ -3759,9 +3772,9 @@ class Text(Widget, XView, YView): elide: bool | None = None, ) -> str: ... # returns empty string for not found - def see(self, index: str | float | _tkinter.Tcl_Obj | Widget) -> None: ... + def see(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget) -> None: ... def tag_add( - self, tagName: str, index1: str | float | _tkinter.Tcl_Obj | Widget, *args: str | float | _tkinter.Tcl_Obj | Widget + self, tagName: str, index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, *args: str | FloatInt | _tkinter.Tcl_Obj | Widget ) -> None: ... # tag_bind stuff is very similar to Canvas @@ -3788,27 +3801,27 @@ class Text(Widget, XView, YView): *, background: str = ..., bgstipple: str = ..., - borderwidth: float | str = ..., - border: float | str = ..., # alias for borderwidth + borderwidth: FloatInt | str = ..., + border: FloatInt | str = ..., # alias for borderwidth elide: bool = ..., fgstipple: str = ..., font: _FontDescription = ..., foreground: str = ..., justify: Literal["left", "right", "center"] = ..., - lmargin1: float | str = ..., - lmargin2: float | str = ..., + lmargin1: FloatInt | str = ..., + lmargin2: FloatInt | str = ..., lmargincolor: str = ..., - offset: float | str = ..., + offset: FloatInt | str = ..., overstrike: bool = ..., overstrikefg: str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., - rmargin: float | str = ..., + rmargin: FloatInt | str = ..., rmargincolor: str = ..., selectbackground: str = ..., selectforeground: str = ..., - spacing1: float | str = ..., - spacing2: float | str = ..., - spacing3: float | str = ..., + spacing1: FloatInt | str = ..., + spacing2: FloatInt | str = ..., + spacing3: FloatInt | str = ..., tabs: Any = ..., # the exact type is kind of complicated, see manual page tabstyle: Literal["tabular", "wordprocessor"] = ..., underline: bool = ..., @@ -3821,18 +3834,18 @@ class Text(Widget, XView, YView): tag_config = tag_configure def tag_delete(self, first_tag_name: str, /, *tagNames: str) -> None: ... # error if no tag names given def tag_lower(self, tagName: str, belowThis: str | None = None) -> None: ... - def tag_names(self, index: str | float | _tkinter.Tcl_Obj | Widget | None = None) -> tuple[str, ...]: ... + def tag_names(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None) -> tuple[str, ...]: ... def tag_nextrange( self, tagName: str, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, ) -> tuple[str, str] | tuple[()]: ... def tag_prevrange( self, tagName: str, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, ) -> tuple[str, str] | tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: str | None = None) -> None: ... def tag_ranges(self, tagName: str) -> tuple[_tkinter.Tcl_Obj, ...]: ... @@ -3840,39 +3853,39 @@ class Text(Widget, XView, YView): def tag_remove( self, tagName: str, - index1: str | float | _tkinter.Tcl_Obj | Widget, - index2: str | float | _tkinter.Tcl_Obj | Widget | None = None, + index1: str | FloatInt | _tkinter.Tcl_Obj | Widget, + index2: str | FloatInt | _tkinter.Tcl_Obj | Widget | None = None, ) -> None: ... @overload - def window_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["padx", "pady"]) -> int: ... + def window_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["padx", "pady"]) -> int: ... @overload def window_cget( - self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["stretch"] + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["stretch"] ) -> bool: ... # actually returns Literal[0, 1] @overload def window_cget( - self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["align"] + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["align"] ) -> Literal["baseline", "bottom", "center", "top"]: ... @overload # window is set to a widget, but read as the string name. - def window_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: Literal["create", "window"]) -> str: ... + def window_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: Literal["create", "window"]) -> str: ... @overload - def window_cget(self, index: str | float | _tkinter.Tcl_Obj | Widget, option: str) -> Any: ... + def window_cget(self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, option: str) -> Any: ... @overload def window_configure( - self, index: str | float | _tkinter.Tcl_Obj | Widget, cnf: str + self, index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: str ) -> tuple[str, str, str, str, str | int]: ... @overload def window_configure( self, - index: str | float | _tkinter.Tcl_Obj | Widget, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: dict[str, Any] | None = None, *, align: Literal["baseline", "bottom", "center", "top"] = ..., create: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., stretch: bool | Literal[0, 1] = ..., window: Misc | str = ..., ) -> dict[str, tuple[str, str, str, str, str | int]] | None: ... @@ -3880,13 +3893,13 @@ class Text(Widget, XView, YView): window_config = window_configure def window_create( self, - index: str | float | _tkinter.Tcl_Obj | Widget, + index: str | FloatInt | _tkinter.Tcl_Obj | Widget, cnf: dict[str, Any] | None = {}, *, align: Literal["baseline", "bottom", "center", "top"] = ..., create: str = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., stretch: bool | Literal[0, 1] = ..., window: Misc | str = ..., ) -> None: ... @@ -3964,7 +3977,7 @@ class PhotoImage(Image, _PhotoImageLike): data: str | bytes = ..., # not same as data argument of put() format: str = ..., file: StrOrBytesPath = ..., - gamma: float = ..., + gamma: FloatInt = ..., height: int = ..., palette: int | str = ..., width: int = ..., @@ -3975,7 +3988,7 @@ class PhotoImage(Image, _PhotoImageLike): data: str | bytes = ..., format: str = ..., file: StrOrBytesPath = ..., - gamma: float = ..., + gamma: FloatInt = ..., height: int = ..., palette: int | str = ..., width: int = ..., @@ -4095,10 +4108,10 @@ class Spinbox(Widget, XView): *, activebackground: str = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., buttonbackground: str = ..., buttoncursor: _Cursor = "", buttondownrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., @@ -4113,16 +4126,16 @@ class Spinbox(Widget, XView): font: _FontDescription = "TkTextFont", foreground: str = ..., format: str = "", - from_: float = 0.0, + from_: FloatInt = 0.0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., - increment: float = 1.0, + highlightthickness: FloatInt | str = ..., + increment: FloatInt = 1.0, insertbackground: str = ..., - insertborderwidth: float | str = 0, + insertborderwidth: FloatInt | str = 0, insertofftime: int = 300, insertontime: int = 600, - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = "", invcmd: str | list[str] | tuple[str, ...] | Callable[[], object] = "", justify: Literal["left", "center", "right"] = "left", @@ -4132,19 +4145,19 @@ class Spinbox(Widget, XView): repeatdelay: int = 400, repeatinterval: int = 100, selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., state: Literal["normal", "disabled", "readonly"] = "normal", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", textvariable: Variable = ..., - to: float = 0.0, + to: FloatInt = 0.0, validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", vcmd: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", values: list[str] | tuple[str, ...] = ..., width: int = 20, wrap: bool = False, - xscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload @@ -4154,10 +4167,10 @@ class Spinbox(Widget, XView): *, activebackground: str = ..., background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., buttonbackground: str = ..., buttoncursor: _Cursor = ..., buttondownrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., @@ -4171,16 +4184,16 @@ class Spinbox(Widget, XView): font: _FontDescription = ..., foreground: str = ..., format: str = ..., - from_: float = ..., + from_: FloatInt = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., - increment: float = ..., + highlightthickness: FloatInt | str = ..., + increment: FloatInt = ..., insertbackground: str = ..., - insertborderwidth: float | str = ..., + insertborderwidth: FloatInt | str = ..., insertofftime: int = ..., insertontime: int = ..., - insertwidth: float | str = ..., + insertwidth: FloatInt | str = ..., invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., invcmd: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., justify: Literal["left", "center", "right"] = ..., @@ -4189,19 +4202,19 @@ class Spinbox(Widget, XView): repeatdelay: int = ..., repeatinterval: int = ..., selectbackground: str = ..., - selectborderwidth: float | str = ..., + selectborderwidth: FloatInt | str = ..., selectforeground: str = ..., state: Literal["normal", "disabled", "readonly"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., textvariable: Variable = ..., - to: float = ..., + to: FloatInt = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., vcmd: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -4235,10 +4248,10 @@ class LabelFrame(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = 2, + bd: FloatInt | str = 2, bg: str = ..., - border: float | str = 2, - borderwidth: float | str = 2, + border: FloatInt | str = 2, + borderwidth: FloatInt | str = 2, class_: str = "Labelframe", # can't be changed with configure() colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() container: bool = False, # undocumented, can't be changed with configure() @@ -4246,21 +4259,21 @@ class LabelFrame(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: float | str = 0, + height: FloatInt | str = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = 0, + highlightthickness: FloatInt | str = 0, # 'ne' and 'en' are valid labelanchors, but only 'ne' is a valid _Anchor. labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = "nw", labelwidget: Misc = ..., name: str = ..., - padx: float | str = 0, - pady: float | str = 0, + padx: FloatInt | str = 0, + pady: FloatInt | str = 0, relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "groove", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = 0, - text: float | str = "", + text: FloatInt | str = "", visual: str | tuple[str, int] = "", # can't be changed with configure() - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -4269,26 +4282,26 @@ class LabelFrame(Widget): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: float | str = ..., + height: FloatInt | str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: float | str = ..., + highlightthickness: FloatInt | str = ..., labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., labelwidget: Misc = ..., - padx: float | str = ..., - pady: float | str = ..., + padx: FloatInt | str = ..., + pady: FloatInt | str = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., - width: float | str = ..., + text: FloatInt | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -4302,27 +4315,27 @@ class PanedWindow(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: float | str = 1, + bd: FloatInt | str = 1, bg: str = ..., - border: float | str = 1, - borderwidth: float | str = 1, + border: FloatInt | str = 1, + borderwidth: FloatInt | str = 1, cursor: _Cursor = "", - handlepad: float | str = 8, - handlesize: float | str = 8, - height: float | str = "", + handlepad: FloatInt | str = 8, + handlesize: FloatInt | str = 8, + height: FloatInt | str = "", name: str = ..., opaqueresize: bool = True, orient: Literal["horizontal", "vertical"] = "horizontal", proxybackground: str = "", - proxyborderwidth: float | str = 2, + proxyborderwidth: FloatInt | str = 2, proxyrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", sashcursor: _Cursor = "", - sashpad: float | str = 0, + sashpad: FloatInt | str = 0, sashrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = "flat", - sashwidth: float | str = 3, + sashwidth: FloatInt | str = 3, showhandle: bool = False, - width: float | str = "", + width: FloatInt | str = "", ) -> None: ... @overload @@ -4331,26 +4344,26 @@ class PanedWindow(Widget): cnf: dict[str, Any] | None = None, *, background: str = ..., - bd: float | str = ..., + bd: FloatInt | str = ..., bg: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: _Cursor = ..., - handlepad: float | str = ..., - handlesize: float | str = ..., - height: float | str = ..., + handlepad: FloatInt | str = ..., + handlesize: FloatInt | str = ..., + height: FloatInt | str = ..., opaqueresize: bool = ..., orient: Literal["horizontal", "vertical"] = ..., proxybackground: str = ..., - proxyborderwidth: float | str = ..., + proxyborderwidth: FloatInt | str = ..., proxyrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., sashcursor: _Cursor = ..., - sashpad: float | str = ..., + sashpad: FloatInt | str = ..., sashrelief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., - sashwidth: float | str = ..., + sashwidth: FloatInt | str = ..., showhandle: bool = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... diff --git a/stdlib/tkinter/simpledialog.pyi b/stdlib/tkinter/simpledialog.pyi index 6f66f0237b45..f25269adf9f6 100644 --- a/stdlib/tkinter/simpledialog.pyi +++ b/stdlib/tkinter/simpledialog.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import FloatInt from tkinter import Event, Frame, Misc, Toplevel if sys.version_info >= (3, 15): @@ -33,9 +34,9 @@ def askfloat( title: str | None, prompt: str, *, - initialvalue: float | None = ..., - minvalue: float | None = ..., - maxvalue: float | None = ..., + initialvalue: FloatInt | None = ..., + minvalue: FloatInt | None = ..., + maxvalue: FloatInt | None = ..., parent: Misc | None = ..., ) -> float | None: ... def askinteger( diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index bb517d39e4e6..5a2b9d3322b0 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from _typeshed import MaybeNone +from _typeshed import FloatInt, MaybeNone from collections.abc import Callable, Iterable, Sequence from tkinter.font import _FontDescription from typing import Any, Literal, ParamSpec, TypeAlias, TypedDict, TypeVar, overload, type_check_only @@ -39,12 +39,12 @@ def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ... def setup_master(master: tkinter.Misc | None = None): ... _Padding: TypeAlias = ( - float + FloatInt | 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] + | tuple[FloatInt | str] + | tuple[FloatInt | str, FloatInt | str] + | tuple[FloatInt | str, FloatInt | str, FloatInt | str] + | tuple[FloatInt | str, FloatInt | str, FloatInt | str, FloatInt | str] ) # Last item (option value to apply) varies between different options so use Any. @@ -72,10 +72,10 @@ _LayoutSpec: TypeAlias = list[tuple[str, _Layout | None]] @type_check_only class _ElementCreateImageKwargs(TypedDict, total=False): border: _Padding - height: float | str + height: FloatInt | str padding: _Padding sticky: str - width: float | str + width: FloatInt | str _ElementCreateArgsCrossPlatform: TypeAlias = ( # Could be any sequence here but types are not homogenous so just type it as tuple @@ -94,8 +94,8 @@ if sys.platform == "win32" and sys.version_info >= (3, 13): @type_check_only class _ElementCreateVsapiKwargsSize(TypedDict): - width: float | str - height: float | str + width: FloatInt | str + height: FloatInt | str _ElementCreateVsapiKwargsDict: TypeAlias = ( _ElementCreateVsapiKwargsPadding | _ElementCreateVsapiKwargsMargin | _ElementCreateVsapiKwargsSize @@ -154,10 +154,10 @@ class Style: /, *imagespec: _ImageStatespec, border: _Padding = ..., - height: float | str = ..., + height: FloatInt | str = ..., padding: _Padding = ..., sticky: str = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> None: ... @overload def element_create(self, elementname: str, etype: Literal["from"], themename: str, fromelement: str = ..., /) -> None: ... @@ -199,8 +199,8 @@ class Style: vs_statespec: _VsapiStatespec = ..., /, *, - width: float | str, - height: float | str, + width: FloatInt | str, + height: FloatInt | str, ) -> None: ... def element_names(self) -> tuple[str, ...]: ... @@ -243,7 +243,7 @@ class Button(Widget): state: str = "normal", style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = "", + text: FloatInt | str = "", textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", @@ -263,7 +263,7 @@ class Button(Widget): state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., @@ -291,7 +291,7 @@ class Checkbutton(Widget): state: str = "normal", style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = "", + text: FloatInt | str = "", textvariable: tkinter.Variable = ..., underline: int = -1, # Seems like variable can be empty string, but actually setting it to @@ -316,7 +316,7 @@ class Checkbutton(Widget): state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., variable: tkinter.Variable = ..., @@ -351,7 +351,7 @@ class Entry(Widget, tkinter.Entry): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", width: int = 20, - xscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload # type: ignore[override] @@ -374,7 +374,7 @@ class Entry(Widget, tkinter.Entry): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -400,7 +400,7 @@ class Entry(Widget, tkinter.Entry): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -434,7 +434,7 @@ class Combobox(Entry): validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented values: list[str] | tuple[str, ...] = ..., width: int = 20, - xscrollcommand: str | Callable[[float, float], object] = ..., # undocumented + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., # undocumented ) -> None: ... @overload # type: ignore[override] @@ -460,7 +460,7 @@ class Combobox(Entry): validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -489,7 +489,7 @@ class Combobox(Entry): validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -504,17 +504,17 @@ class Frame(Widget): self, master: tkinter.Misc | None = None, *, - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., class_: str = "", cursor: tkinter._Cursor = "", - height: float | str = 0, + height: FloatInt | str = 0, name: str = ..., padding: _Padding = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -522,15 +522,15 @@ class Frame(Widget): self, cnf: dict[str, Any] | None = None, *, - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: tkinter._Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., padding: _Padding = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -544,8 +544,8 @@ class Label(Widget): *, anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = "", - border: float | str = ..., # alias for borderwidth - borderwidth: float | str = ..., # undocumented + border: FloatInt | str = ..., # alias for borderwidth + borderwidth: FloatInt | str = ..., # undocumented class_: str = "", compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = "", cursor: tkinter._Cursor = "", @@ -559,11 +559,11 @@ class Label(Widget): state: str = "normal", style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: FloatInt | str = "", textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", - wraplength: float | str = ..., + wraplength: FloatInt | str = ..., ) -> None: ... @overload @@ -573,8 +573,8 @@ class Label(Widget): *, anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., background: str = ..., - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., compound: Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"] = ..., cursor: tkinter._Cursor = ..., font: _FontDescription = ..., @@ -586,11 +586,11 @@ class Label(Widget): state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., - wraplength: float | str = ..., + wraplength: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -602,11 +602,11 @@ class Labelframe(Widget): self, master: tkinter.Misc | None = None, *, - border: float | str = ..., - borderwidth: float | str = ..., # undocumented + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., # undocumented class_: str = "", cursor: tkinter._Cursor = "", - height: float | str = 0, + height: FloatInt | str = 0, labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., labelwidget: tkinter.Misc = ..., name: str = ..., @@ -614,9 +614,9 @@ class Labelframe(Widget): relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., # undocumented style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: FloatInt | str = "", underline: int = -1, - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... @overload @@ -624,19 +624,19 @@ class Labelframe(Widget): self, cnf: dict[str, Any] | None = None, *, - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., cursor: tkinter._Cursor = ..., - height: float | str = ..., + height: FloatInt | str = ..., labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., labelwidget: tkinter.Misc = ..., padding: _Padding = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., underline: int = ..., - width: float | str = ..., + width: FloatInt | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -661,7 +661,7 @@ class Menubutton(Widget): state: str = "normal", style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = "", + text: FloatInt | str = "", textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", @@ -681,7 +681,7 @@ class Menubutton(Widget): state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., @@ -810,18 +810,18 @@ class Progressbar(Widget): font: _FontDescription = ..., # new in Tcl/Tk 9.0 foreground: str = ..., # new in Tcl/Tk 9.0 justify: Literal["left", "center", "right"] = ..., # new in Tcl/Tk 9.0 - length: float | str = 100, - maximum: float = 100, + length: FloatInt | str = 100, + maximum: FloatInt = 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: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", # new in Tcl/Tk 9.0 - value: float = 0.0, + text: FloatInt | str = "", # new in Tcl/Tk 9.0 + value: FloatInt = 0.0, variable: tkinter.IntVar | tkinter.DoubleVar = ..., - wraplength: float | str = ..., # new in Tcl/Tk 9.0 + wraplength: FloatInt | str = ..., # new in Tcl/Tk 9.0 ) -> None: ... @overload @@ -834,24 +834,24 @@ class Progressbar(Widget): font: _FontDescription = ..., # new in Tcl/Tk 9.0 foreground: str = ..., # new in Tcl/Tk 9.0 justify: Literal["left", "center", "right"] = ..., # new in Tcl/Tk 9.0 - length: float | str = ..., - maximum: float = ..., + length: FloatInt | str = ..., + maximum: FloatInt = ..., mode: Literal["determinate", "indeterminate"] = ..., orient: Literal["horizontal", "vertical"] = ..., phase: int = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., # new in Tcl/Tk 9.0 - value: float = ..., + text: FloatInt | str = ..., # new in Tcl/Tk 9.0 + value: FloatInt = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., - wraplength: float | str = ..., # new in Tcl/Tk 9.0 + wraplength: FloatInt | str = ..., # new in Tcl/Tk 9.0 ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def start(self, interval: Literal["idle"] | int | None = None) -> None: ... - def step(self, amount: float | None = None) -> None: ... + def step(self, amount: FloatInt | None = None) -> None: ... def stop(self) -> None: ... class Radiobutton(Widget): @@ -869,7 +869,7 @@ class Radiobutton(Widget): state: str = "normal", style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = "", + text: FloatInt | str = "", textvariable: tkinter.Variable = ..., underline: int = -1, value: Any = "1", @@ -890,7 +890,7 @@ class Radiobutton(Widget): state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: FloatInt | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., @@ -912,15 +912,15 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] class_: str = "", command: str | Callable[[str], object] = "", cursor: tkinter._Cursor = "", - from_: float = 0, - length: float | str = 100, + from_: FloatInt = 0, + length: FloatInt | str = 100, name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", state: str = ..., # undocumented style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - to: float = 1.0, - value: float = 0, + to: FloatInt = 1.0, + value: FloatInt = 0, variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> None: ... @@ -931,14 +931,14 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] *, command: str | Callable[[str], object] = ..., cursor: tkinter._Cursor = ..., - from_: float = ..., - length: float | str = ..., + from_: FloatInt = ..., + length: FloatInt | str = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - to: float = ..., - value: float = ..., + to: FloatInt = ..., + value: FloatInt = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -952,14 +952,14 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] *, command: str | Callable[[str], object] = ..., cursor: tkinter._Cursor = ..., - from_: float = ..., - length: float | str = ..., + from_: FloatInt = ..., + length: FloatInt | str = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - to: float = ..., - value: float = ..., + to: FloatInt = ..., + value: FloatInt = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -1078,8 +1078,8 @@ class Spinbox(Entry): font: _FontDescription = ..., # undocumented foreground: str = ..., # undocumented format: str = "", - from_: float = 0, - increment: float = 1, + from_: FloatInt = 0, + increment: FloatInt = 1, invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., # undocumented justify: Literal["left", "center", "right"] = ..., # undocumented name: str = ..., @@ -1088,13 +1088,13 @@ class Spinbox(Entry): style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., textvariable: tkinter.Variable = ..., # undocumented - to: float = 0, + to: FloatInt = 0, validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "", values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = False, - xscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload # type: ignore[override] @@ -1109,8 +1109,8 @@ class Spinbox(Entry): font: _FontDescription = ..., foreground: str = ..., format: str = ..., - from_: float = ..., - increment: float = ..., + from_: FloatInt = ..., + increment: FloatInt = ..., invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], object] = ..., justify: Literal["left", "center", "right"] = ..., show=..., @@ -1118,13 +1118,13 @@ class Spinbox(Entry): style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., textvariable: tkinter.Variable = ..., - to: float = ..., + to: FloatInt = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1184,8 +1184,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ("tree", "headings"), style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - xscrollcommand: str | Callable[[float, float], object] = "", - yscrollcommand: str | Callable[[float, float], object] = "", + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = "", ) -> None: ... @overload @@ -1202,8 +1202,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - xscrollcommand: str | Callable[[float, float], object] = ..., - yscrollcommand: str | Callable[[float, float], object] = ..., + xscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., + yscrollcommand: str | Callable[[FloatInt, FloatInt], object] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1396,21 +1396,21 @@ class LabeledScale(Frame): self, master: tkinter.Misc | None = None, variable: tkinter.IntVar | tkinter.DoubleVar | None = None, - from_: float = 0, - to: float = 10, + from_: FloatInt = 0, + to: FloatInt = 10, *, - border: float | str = ..., - borderwidth: float | str = ..., + border: FloatInt | str = ..., + borderwidth: FloatInt | str = ..., class_: str = "", compound: Literal["top", "bottom"] = "top", cursor: tkinter._Cursor = "", - height: float | str = 0, + height: FloatInt | str = 0, name: str = ..., padding: _Padding = ..., relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - width: float | str = 0, + width: FloatInt | str = 0, ) -> None: ... # destroy is overridden, signature does not change value: Any diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 1152e9603335..427aaa8c0494 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import StrPath +from _typeshed import FloatInt, StrPath from collections.abc import Callable, Generator, Sequence from contextlib import contextmanager from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar @@ -143,7 +143,7 @@ if sys.version_info < (3, 13): # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color: TypeAlias = str | tuple[float, float, float] +_Color: TypeAlias = str | tuple[FloatInt, FloatInt, FloatInt] _AnyColor: TypeAlias = Any @type_check_only @@ -155,46 +155,46 @@ class _PenState(TypedDict): pensize: int speed: int resizemode: Literal["auto", "user", "noresize"] - stretchfactor: tuple[float, float] - shearfactor: float + stretchfactor: tuple[FloatInt, FloatInt] + shearfactor: FloatInt outline: int - tilt: float + tilt: FloatInt -_Speed: TypeAlias = str | float -_PolygonCoords: TypeAlias = Sequence[tuple[float, float]] +_Speed: TypeAlias = str | FloatInt +_PolygonCoords: TypeAlias = Sequence[tuple[FloatInt, FloatInt]] if sys.version_info >= (3, 12): class Vec2D(tuple[float, float]): - def __new__(cls, x: float, y: float) -> Self: ... - def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override] + def __new__(cls, x: FloatInt, y: FloatInt) -> Self: ... + def __add__(self, other: tuple[FloatInt, FloatInt]) -> Vec2D: ... # type: ignore[override] @overload # type: ignore[override] def __mul__(self, other: Vec2D) -> float: ... @overload - def __mul__(self, other: float) -> Vec2D: ... + def __mul__(self, other: FloatInt) -> Vec2D: ... - def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override] - def __sub__(self, other: tuple[float, float]) -> Vec2D: ... + def __rmul__(self, other: FloatInt) -> Vec2D: ... # type: ignore[override] + def __sub__(self, other: tuple[FloatInt, FloatInt]) -> Vec2D: ... def __neg__(self) -> Vec2D: ... def __abs__(self) -> float: ... - def rotate(self, angle: float) -> Vec2D: ... + def rotate(self, angle: FloatInt) -> Vec2D: ... else: @disjoint_base class Vec2D(tuple[float, float]): - def __new__(cls, x: float, y: float) -> Self: ... - def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override] + def __new__(cls, x: FloatInt, y: FloatInt) -> Self: ... + def __add__(self, other: tuple[FloatInt, FloatInt]) -> Vec2D: ... # type: ignore[override] @overload # type: ignore[override] def __mul__(self, other: Vec2D) -> float: ... @overload - def __mul__(self, other: float) -> Vec2D: ... + def __mul__(self, other: FloatInt) -> Vec2D: ... - def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override] - def __sub__(self, other: tuple[float, float]) -> Vec2D: ... + def __rmul__(self, other: FloatInt) -> Vec2D: ... # type: ignore[override] + def __sub__(self, other: tuple[FloatInt, FloatInt]) -> Vec2D: ... def __neg__(self) -> Vec2D: ... def __abs__(self) -> float: ... - def rotate(self, angle: float) -> Vec2D: ... + def rotate(self, angle: FloatInt) -> Vec2D: ... # Does not actually inherit from Canvas, but dynamically gets all methods of Canvas class ScrolledCanvas(Canvas, Frame): # type: ignore[misc] # pyrefly: ignore [inconsistent-inheritance] @@ -212,13 +212,18 @@ class TurtleScreenBase: cv: Canvas canvwidth: int canvheight: int - xscale: float - yscale: float + xscale: FloatInt + yscale: FloatInt def __init__(self, cv: Canvas) -> None: ... def mainloop(self) -> None: ... def textinput(self, title: str, prompt: str) -> str | None: ... def numinput( - self, title: str, prompt: str, default: float | None = None, minval: float | None = None, maxval: float | None = None + self, + title: str, + prompt: str, + default: FloatInt | None = None, + minval: FloatInt | None = None, + maxval: FloatInt | None = None, ) -> float | None: ... class Terminator(Exception): ... @@ -232,7 +237,7 @@ class Shape: class TurtleScreen(TurtleScreenBase): def __init__( - self, cv: Canvas, mode: Literal["standard", "logo", "world"] = "standard", colormode: float = 1.0, delay: int = 10 + self, cv: Canvas, mode: Literal["standard", "logo", "world"] = "standard", colormode: FloatInt = 1.0, delay: int = 10 ) -> None: ... def clear(self) -> None: ... @@ -241,13 +246,13 @@ class TurtleScreen(TurtleScreenBase): @overload def mode(self, mode: Literal["standard", "logo", "world"]) -> None: ... - def setworldcoordinates(self, llx: float, lly: float, urx: float, ury: float) -> None: ... + def setworldcoordinates(self, llx: FloatInt, lly: FloatInt, urx: FloatInt, ury: FloatInt) -> None: ... def register_shape(self, name: str, shape: _PolygonCoords | Shape | None = None) -> None: ... @overload def colormode(self, cmode: None = None) -> float: ... @overload - def colormode(self, cmode: float) -> None: ... + def colormode(self, cmode: FloatInt) -> None: ... def reset(self) -> None: ... def turtles(self) -> list[Turtle]: ... @@ -257,7 +262,7 @@ class TurtleScreen(TurtleScreenBase): @overload def bgcolor(self, color: _Color) -> None: ... @overload - def bgcolor(self, r: float, g: float, b: float) -> None: ... + def bgcolor(self, r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def tracer(self, n: None = None) -> int: ... @@ -278,9 +283,9 @@ class TurtleScreen(TurtleScreenBase): def window_height(self) -> int: ... def getcanvas(self) -> Canvas: ... def getshapes(self) -> list[str]: ... - def onclick(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... + def onclick(self, fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... def onkey(self, fun: Callable[[], object], key: str) -> None: ... - def listen(self, xdummy: float | None = None, ydummy: float | None = None) -> None: ... + def listen(self, xdummy: FloatInt | None = None, ydummy: FloatInt | None = None) -> None: ... def ontimer(self, fun: Callable[[], object], t: int = 0) -> None: ... @overload @@ -310,41 +315,41 @@ class TNavigator: DEFAULT_ANGLEORIENT: int def __init__(self, mode: Literal["standard", "logo", "world"] = "standard") -> None: ... def reset(self) -> None: ... - def degrees(self, fullcircle: float = 360.0) -> None: ... + def degrees(self, fullcircle: FloatInt = 360.0) -> None: ... def radians(self) -> None: ... if sys.version_info >= (3, 12): - def teleport(self, x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ... + def teleport(self, x: FloatInt | None = None, y: FloatInt | None = None, *, fill_gap: bool = False) -> None: ... - def forward(self, distance: float) -> None: ... - def back(self, distance: float) -> None: ... - def right(self, angle: float) -> None: ... - def left(self, angle: float) -> None: ... + def forward(self, distance: FloatInt) -> None: ... + def back(self, distance: FloatInt) -> None: ... + def right(self, angle: FloatInt) -> None: ... + def left(self, angle: FloatInt) -> None: ... def pos(self) -> Vec2D: ... def xcor(self) -> float: ... def ycor(self) -> float: ... @overload - def goto(self, x: tuple[float, float], y: None = None) -> None: ... + def goto(self, x: tuple[FloatInt, FloatInt], y: None = None) -> None: ... @overload - def goto(self, x: float, y: float) -> None: ... + def goto(self, x: FloatInt, y: FloatInt) -> None: ... def home(self) -> None: ... - def setx(self, x: float) -> None: ... - def sety(self, y: float) -> None: ... + def setx(self, x: FloatInt) -> None: ... + def sety(self, y: FloatInt) -> None: ... @overload - def distance(self, x: TNavigator | tuple[float, float], y: None = None) -> float: ... + def distance(self, x: TNavigator | tuple[FloatInt, FloatInt], y: None = None) -> float: ... @overload - def distance(self, x: float, y: float) -> float: ... + def distance(self, x: FloatInt, y: FloatInt) -> float: ... @overload - def towards(self, x: TNavigator | tuple[float, float], y: None = None) -> float: ... + def towards(self, x: TNavigator | tuple[FloatInt, FloatInt], y: None = None) -> float: ... @overload - def towards(self, x: float, y: float) -> float: ... + def towards(self, x: FloatInt, y: FloatInt) -> float: ... def heading(self) -> float: ... - def setheading(self, to_angle: float) -> None: ... - def circle(self, radius: float, extent: float | None = None, steps: int | None = None) -> None: ... + def setheading(self, to_angle: FloatInt) -> None: ... + def circle(self, radius: FloatInt, extent: FloatInt | None = None, steps: int | None = None) -> None: ... def speed(self, s: int | None = 0) -> int | None: ... fd = forward bk = back @@ -383,26 +388,26 @@ class TPen: @overload def pencolor(self, color: _Color) -> None: ... @overload - def pencolor(self, r: float, g: float, b: float) -> None: ... + def pencolor(self, r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def fillcolor(self) -> _AnyColor: ... @overload def fillcolor(self, color: _Color) -> None: ... @overload - def fillcolor(self, r: float, g: float, b: float) -> None: ... + def fillcolor(self, r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def color(self) -> tuple[_AnyColor, _AnyColor]: ... @overload def color(self, color: _Color) -> None: ... @overload - def color(self, r: float, g: float, b: float) -> None: ... + def color(self, r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def color(self, color1: _Color, color2: _Color) -> None: ... if sys.version_info >= (3, 12): - def teleport(self, x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ... + def teleport(self, x: FloatInt | None = None, y: FloatInt | None = None, *, fill_gap: bool = False) -> None: ... def showturtle(self) -> None: ... def hideturtle(self) -> None: ... @@ -423,9 +428,9 @@ class TPen: pensize: int = ..., speed: int = ..., resizemode: Literal["auto", "user", "noresize"] = ..., - stretchfactor: tuple[float, float] = ..., + stretchfactor: tuple[FloatInt, FloatInt] = ..., outline: int = ..., - tilt: float = ..., + tilt: FloatInt = ..., ) -> None: ... width = pensize @@ -462,34 +467,34 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods def shapesize(self) -> tuple[float, float, float]: ... @overload def shapesize( - self, stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None + self, stretch_wid: FloatInt | None = None, stretch_len: FloatInt | None = None, outline: FloatInt | None = None ) -> None: ... @overload def shearfactor(self, shear: None = None) -> float: ... @overload - def shearfactor(self, shear: float) -> None: ... + def shearfactor(self, shear: FloatInt) -> None: ... # Unsafely overlaps when no arguments are provided @overload def shapetransform(self) -> tuple[float, float, float, float]: ... @overload def shapetransform( - self, t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None + self, t11: FloatInt | None = None, t12: FloatInt | None = None, t21: FloatInt | None = None, t22: FloatInt | None = None ) -> None: ... def get_shapepoly(self) -> _PolygonCoords | None: ... if sys.version_info < (3, 13): @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.") - def settiltangle(self, angle: float) -> None: ... + def settiltangle(self, angle: FloatInt) -> None: ... @overload def tiltangle(self, angle: None = None) -> float: ... @overload - def tiltangle(self, angle: float) -> None: ... + def tiltangle(self, angle: FloatInt) -> None: ... - def tilt(self, angle: float) -> None: ... + def tilt(self, angle: FloatInt) -> None: ... # Can return either 'int' or Tuple[int, ...] based on if the stamp is # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. @@ -509,7 +514,7 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods @overload def dot(self, size: int | None, color: _Color, /) -> None: ... @overload - def dot(self, size: int | None, r: float, g: float, b: float, /) -> None: ... + def dot(self, size: int | None, r: FloatInt, g: FloatInt, b: FloatInt, /) -> None: ... def write( self, arg: object, move: bool = False, align: str = "left", font: tuple[str, int, str] = ("Arial", 8, "normal") @@ -524,19 +529,19 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods def getscreen(self) -> TurtleScreen: ... def getturtle(self) -> Self: ... getpen = getturtle - def onclick(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... - def onrelease(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... - def ondrag(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... + def onclick(self, fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... + def onrelease(self, fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... + def ondrag(self, fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... def undo(self) -> None: ... turtlesize = shapesize class _Screen(TurtleScreen): def __init__(self) -> None: ... - # Note int and float are interpreted differently, hence the Union instead of just float + # Note int and float are interpreted differently def setup( self, - width: int | float = 0.5, # noqa: Y041 - height: int | float = 0.75, # noqa: Y041 + width: int | float = 0.5, + height: int | float = 0.75, startx: int | None = None, starty: int | None = None, ) -> None: ... @@ -557,7 +562,7 @@ def write_docstringdict(filename: str = "turtle_docstringdict") -> None: ... def mainloop() -> None: ... def textinput(title: str, prompt: str) -> str | None: ... def numinput( - title: str, prompt: str, default: float | None = None, minval: float | None = None, maxval: float | None = None + title: str, prompt: str, default: FloatInt | None = None, minval: FloatInt | None = None, maxval: FloatInt | None = None ) -> float | None: ... # Functions copied from TurtleScreen: @@ -569,13 +574,13 @@ def mode(mode: None = None) -> str: ... @overload def mode(mode: Literal["standard", "logo", "world"]) -> None: ... -def setworldcoordinates(llx: float, lly: float, urx: float, ury: float) -> None: ... +def setworldcoordinates(llx: FloatInt, lly: FloatInt, urx: FloatInt, ury: FloatInt) -> None: ... def register_shape(name: str, shape: _PolygonCoords | Shape | None = None) -> None: ... @overload def colormode(cmode: None = None) -> float: ... @overload -def colormode(cmode: float) -> None: ... +def colormode(cmode: FloatInt) -> None: ... def reset() -> None: ... def turtles() -> list[Turtle]: ... @@ -585,7 +590,7 @@ def bgcolor() -> _AnyColor: ... @overload def bgcolor(color: _Color) -> None: ... @overload -def bgcolor(r: float, g: float, b: float) -> None: ... +def bgcolor(r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def tracer(n: None = None) -> int: ... @@ -606,9 +611,9 @@ def window_width() -> int: ... def window_height() -> int: ... def getcanvas() -> Canvas: ... def getshapes() -> list[str]: ... -def onclick(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... +def onclick(fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... def onkey(fun: Callable[[], object], key: str) -> None: ... -def listen(xdummy: float | None = None, ydummy: float | None = None) -> None: ... +def listen(xdummy: FloatInt | None = None, ydummy: FloatInt | None = None) -> None: ... def ontimer(fun: Callable[[], object], t: int = 0) -> None: ... @overload @@ -635,7 +640,7 @@ onkeyrelease = onkey # Functions copied from _Screen: -def setup(width: float = 0.5, height: float = 0.75, startx: int | None = None, starty: int | None = None) -> None: ... +def setup(width: FloatInt = 0.5, height: FloatInt = 0.75, startx: int | None = None, starty: int | None = None) -> None: ... def title(titlestring: str) -> None: ... def bye() -> None: ... def exitonclick() -> None: ... @@ -643,38 +648,38 @@ def Screen() -> _Screen: ... # Functions copied from TNavigator: -def degrees(fullcircle: float = 360.0) -> None: ... +def degrees(fullcircle: FloatInt = 360.0) -> None: ... def radians() -> None: ... -def forward(distance: float) -> None: ... -def back(distance: float) -> None: ... -def right(angle: float) -> None: ... -def left(angle: float) -> None: ... +def forward(distance: FloatInt) -> None: ... +def back(distance: FloatInt) -> None: ... +def right(angle: FloatInt) -> None: ... +def left(angle: FloatInt) -> None: ... def pos() -> Vec2D: ... def xcor() -> float: ... def ycor() -> float: ... @overload -def goto(x: tuple[float, float], y: None = None) -> None: ... +def goto(x: tuple[FloatInt, FloatInt], y: None = None) -> None: ... @overload -def goto(x: float, y: float) -> None: ... +def goto(x: FloatInt, y: FloatInt) -> None: ... def home() -> None: ... -def setx(x: float) -> None: ... -def sety(y: float) -> None: ... +def setx(x: FloatInt) -> None: ... +def sety(y: FloatInt) -> None: ... @overload -def distance(x: TNavigator | tuple[float, float], y: None = None) -> float: ... +def distance(x: TNavigator | tuple[FloatInt, FloatInt], y: None = None) -> float: ... @overload -def distance(x: float, y: float) -> float: ... +def distance(x: FloatInt, y: FloatInt) -> float: ... @overload -def towards(x: TNavigator | tuple[float, float], y: None = None) -> float: ... +def towards(x: TNavigator | tuple[FloatInt, FloatInt], y: None = None) -> float: ... @overload -def towards(x: float, y: float) -> float: ... +def towards(x: FloatInt, y: FloatInt) -> float: ... def heading() -> float: ... -def setheading(to_angle: float) -> None: ... -def circle(radius: float, extent: float | None = None, steps: int | None = None) -> None: ... +def setheading(to_angle: FloatInt) -> None: ... +def circle(radius: FloatInt, extent: FloatInt | None = None, steps: int | None = None) -> None: ... fd = forward bk = back @@ -711,21 +716,21 @@ def pencolor() -> _AnyColor: ... @overload def pencolor(color: _Color) -> None: ... @overload -def pencolor(r: float, g: float, b: float) -> None: ... +def pencolor(r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def fillcolor() -> _AnyColor: ... @overload def fillcolor(color: _Color) -> None: ... @overload -def fillcolor(r: float, g: float, b: float) -> None: ... +def fillcolor(r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def color() -> tuple[_AnyColor, _AnyColor]: ... @overload def color(color: _Color) -> None: ... @overload -def color(r: float, g: float, b: float) -> None: ... +def color(r: FloatInt, g: FloatInt, b: FloatInt) -> None: ... @overload def color(color1: _Color, color2: _Color) -> None: ... @@ -747,9 +752,9 @@ def pen( pensize: int = ..., speed: int = ..., resizemode: Literal["auto", "user", "noresize"] = ..., - stretchfactor: tuple[float, float] = ..., + stretchfactor: tuple[FloatInt, FloatInt] = ..., outline: int = ..., - tilt: float = ..., + tilt: FloatInt = ..., ) -> None: ... width = pensize @@ -771,39 +776,41 @@ def shape(name: None = None) -> str: ... def shape(name: str) -> None: ... if sys.version_info >= (3, 12): - def teleport(x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ... + def teleport(x: FloatInt | None = None, y: FloatInt | None = None, *, fill_gap: bool = False) -> None: ... # Unsafely overlaps when no arguments are provided @overload def shapesize() -> tuple[float, float, float]: ... @overload -def shapesize(stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None) -> None: ... +def shapesize( + stretch_wid: FloatInt | None = None, stretch_len: FloatInt | None = None, outline: FloatInt | None = None +) -> None: ... @overload def shearfactor(shear: None = None) -> float: ... @overload -def shearfactor(shear: float) -> None: ... +def shearfactor(shear: FloatInt) -> None: ... # Unsafely overlaps when no arguments are provided @overload def shapetransform() -> tuple[float, float, float, float]: ... @overload def shapetransform( - t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None + t11: FloatInt | None = None, t12: FloatInt | None = None, t21: FloatInt | None = None, t22: FloatInt | None = None ) -> None: ... def get_shapepoly() -> _PolygonCoords | None: ... if sys.version_info < (3, 13): @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.") - def settiltangle(angle: float) -> None: ... + def settiltangle(angle: FloatInt) -> None: ... @overload def tiltangle(angle: None = None) -> float: ... @overload -def tiltangle(angle: float) -> None: ... +def tiltangle(angle: FloatInt) -> None: ... -def tilt(angle: float) -> None: ... +def tilt(angle: FloatInt) -> None: ... # Can return either 'int' or Tuple[int, ...] based on if the stamp is # a compound stamp or not. So, as per the "no Union return" policy, @@ -825,7 +832,7 @@ def dot(size: int | _Color | None = None) -> None: ... @overload def dot(size: int | None, color: _Color, /) -> None: ... @overload -def dot(size: int | None, r: float, g: float, b: float, /) -> None: ... +def dot(size: int | None, r: FloatInt, g: FloatInt, b: FloatInt, /) -> None: ... def write(arg: object, move: bool = False, align: str = "left", font: tuple[str, int, str] = ("Arial", 8, "normal")) -> None: ... @@ -841,8 +848,8 @@ def getturtle() -> Turtle: ... getpen = getturtle -def onrelease(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... -def ondrag(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ... +def onrelease(fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... +def ondrag(fun: Callable[[FloatInt, FloatInt], object], btn: int = 1, add: bool | None = None) -> None: ... def undo() -> None: ... turtlesize = shapesize diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index de88e30f0fe3..2cf08c4e04f9 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import MaybeNone +from _typeshed import FloatInt, MaybeNone from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence from contextlib import _GeneratorContextManager from types import TracebackType @@ -542,12 +542,12 @@ class PropertyMock(Mock): if sys.version_info >= (3, 13): class ThreadingMixin(Base): - DEFAULT_TIMEOUT: Final[float | None] = None + DEFAULT_TIMEOUT: Final[FloatInt | None] = None - def __init__(self, /, *args: Any, timeout: float | _SentinelObject | None = ..., **kwargs: Any) -> None: ... + def __init__(self, /, *args: Any, timeout: FloatInt | _SentinelObject | None = ..., **kwargs: Any) -> None: ... # Same as `NonCallableMock.reset_mock.` def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ... - def wait_until_called(self, *, timeout: float | _SentinelObject | None = ...) -> None: ... + def wait_until_called(self, *, timeout: FloatInt | _SentinelObject | None = ...) -> None: ... def wait_until_any_call_with(self, *args: Any, **kwargs: Any) -> None: ... class ThreadingMock(ThreadingMixin, MagicMixin, Mock): ... diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 081f6e1328e4..c4d2573f577b 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,11 +1,11 @@ import sys import unittest.case -from _typeshed import OptExcInfo +from _typeshed import FloatInt, OptExcInfo from collections.abc import Callable from typing import Any, Final, TextIO, TypeAlias, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) -_DurationsType: TypeAlias = list[tuple[str, float]] +_DurationsType: TypeAlias = list[tuple[str, FloatInt]] STDOUT_LINE: Final[str] STDERR_LINE: Final[str] @@ -43,4 +43,4 @@ class TestResult: def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: ... def addSubTest(self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: OptExcInfo | None) -> None: ... if sys.version_info >= (3, 12): - def addDuration(self, test: unittest.case.TestCase, elapsed: float) -> None: ... + def addDuration(self, test: unittest.case.TestCase, elapsed: FloatInt) -> None: ... diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index d81d3a2f8698..106f05955f8b 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -1,6 +1,6 @@ import ssl import sys -from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsItems, SupportsRead +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath, SupportsItems, SupportsRead from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from email.message import Message from http.client import HTTPConnection, HTTPMessage, HTTPResponse @@ -61,7 +61,11 @@ _DataType: TypeAlias = ReadableBuffer | SupportsRead[bytes] | Iterable[bytes] | if sys.version_info >= (3, 13): def urlopen( - url: str | Request, data: _DataType | None = None, timeout: float | None = ..., *, context: ssl.SSLContext | None = None + url: str | Request, + data: _DataType | None = None, + timeout: FloatInt | None = ..., + *, + context: ssl.SSLContext | None = None, ) -> _UrlopenRet: ... else: @@ -69,7 +73,7 @@ else: def urlopen( url: str | Request, data: _DataType | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., *, cafile: None = None, capath: None = None, @@ -84,7 +88,7 @@ else: def urlopen( url: str | Request, data: _DataType | None = None, - timeout: float | None = ..., + timeout: FloatInt | None = ..., *, cafile: StrOrBytesPath | None = None, capath: StrOrBytesPath | None = None, @@ -138,7 +142,7 @@ class Request: unredirected_hdrs: dict[str, str] unverifiable: bool method: str | None - timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open() + timeout: FloatInt | None # Undocumented, only set after __init__() by OpenerDirector.open() def __init__( self, url: str, @@ -167,7 +171,7 @@ class Request: class OpenerDirector: addheaders: list[tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... - def open(self, fullurl: str | Request, data: _DataType = None, timeout: float | None = ...) -> _UrlopenRet: ... + def open(self, fullurl: str | Request, data: _DataType = None, timeout: FloatInt | None = ...) -> _UrlopenRet: ... def error(self, proto: str, *args: Any) -> _UrlopenRet: ... def close(self) -> None: ... @@ -275,7 +279,7 @@ class _HTTPConnectionProtocol(Protocol): /, *, port: int | None = ..., - timeout: float = ..., + timeout: FloatInt = ..., source_address: tuple[str, int] | None = ..., blocksize: int = ..., ) -> HTTPConnection: ... @@ -318,7 +322,7 @@ class DataHandler(BaseHandler): class ftpwrapper: # undocumented def __init__( - self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: float | None = None, persistent: bool = True + self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: FloatInt | None = None, persistent: bool = True ) -> None: ... def close(self) -> None: ... def endtransfer(self) -> None: ... @@ -330,11 +334,11 @@ class ftpwrapper: # undocumented class FTPHandler(BaseHandler): def ftp_open(self, req: Request) -> addinfourl: ... def connect_ftp( - self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: float + self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: FloatInt ) -> ftpwrapper: ... # undocumented class CacheFTPHandler(FTPHandler): - def setTimeout(self, t: float) -> None: ... + def setTimeout(self, t: FloatInt) -> None: ... def setMaxConns(self, m: int) -> None: ... def check_cache(self) -> None: ... # undocumented def clear_cache(self) -> None: ... # undocumented diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index 8ec5ce8154cd..b8e5f17dc83b 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, StrOrBytesPath, Unused +from _typeshed import FloatInt, ReadableBuffer, StrOrBytesPath, Unused from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, TypeAlias, overload from typing_extensions import Never, Self, deprecated @@ -64,7 +64,7 @@ class Wave_write: def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... def getsampwidth(self) -> int: ... - def setframerate(self, framerate: float) -> None: ... + def setframerate(self, framerate: FloatInt) -> None: ... def getframerate(self) -> int: ... if sys.version_info >= (3, 15): def setformat(self, format: int) -> None: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index ebead540018e..9e948bc1cf25 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,4 +1,4 @@ -from _typeshed import OptExcInfo +from _typeshed import FloatInt, OptExcInfo from _typeshed.wsgi import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from abc import abstractmethod from collections.abc import Callable, MutableMapping @@ -9,7 +9,7 @@ from .util import FileWrapper __all__ = ["BaseHandler", "SimpleHandler", "BaseCGIHandler", "CGIHandler", "IISCGIHandler", "read_environ"] -def format_date_time(timestamp: float | None) -> str: ... # undocumented +def format_date_time(timestamp: FloatInt | None) -> str: ... # undocumented def read_environ() -> dict[str, str]: ... class BaseHandler: diff --git a/stdlib/xdrlib.pyi b/stdlib/xdrlib.pyi index 78f3ecec8d78..ad873d02ba00 100644 --- a/stdlib/xdrlib.pyi +++ b/stdlib/xdrlib.pyi @@ -1,3 +1,4 @@ +from _typeshed import FloatInt from collections.abc import Callable, Sequence from typing import TypeVar @@ -21,8 +22,8 @@ class Packer: def pack_bool(self, x: bool) -> None: ... def pack_uhyper(self, x: int) -> None: ... def pack_hyper(self, x: int) -> None: ... - def pack_float(self, x: float) -> None: ... - def pack_double(self, x: float) -> None: ... + def pack_float(self, x: FloatInt) -> None: ... + def pack_double(self, x: FloatInt) -> None: ... def pack_fstring(self, n: int, s: bytes) -> None: ... def pack_fopaque(self, n: int, s: bytes) -> None: ... def pack_string(self, s: bytes) -> None: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 3107f1cbb377..ec37e68d80e9 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -1,7 +1,7 @@ import gzip import http.client import time -from _typeshed import ReadableBuffer, SizedBuffer, SupportsRead, SupportsWrite +from _typeshed import FloatInt, ReadableBuffer, SizedBuffer, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Mapping from datetime import datetime from io import BytesIO @@ -16,8 +16,8 @@ class _SupportsTimeTuple(Protocol): _DateTimeComparable: TypeAlias = DateTime | datetime | str | _SupportsTimeTuple _Marshallable: TypeAlias = ( bool - | int | float + | int | str | bytes | bytearray @@ -123,7 +123,7 @@ class Marshaller: def dump_bool(self, value: bool, write: _WriteCallback) -> None: ... def dump_long(self, value: int, write: _WriteCallback) -> None: ... def dump_int(self, value: int, write: _WriteCallback) -> None: ... - def dump_double(self, value: float, write: _WriteCallback) -> None: ... + def dump_double(self, value: FloatInt, write: _WriteCallback) -> None: ... def dump_unicode(self, value: str, write: _WriteCallback, escape: Callable[[str], str] = ...) -> None: ... def dump_bytes(self, value: ReadableBuffer, write: _WriteCallback) -> None: ... def dump_array(self, value: Iterable[_Marshallable], write: _WriteCallback) -> None: ... From 1708ffd5e7483327dc9da0d5714dc9ae5bc41693 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:15:46 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/marshal.pyi | 5 ++++- stdlib/turtle.pyi | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/stdlib/marshal.pyi b/stdlib/marshal.pyi index f7410ea662ed..04cdf05b1934 100644 --- a/stdlib/marshal.pyi +++ b/stdlib/marshal.pyi @@ -20,7 +20,10 @@ _Marshallable: TypeAlias = ( | types.CodeType | ReadableBuffer # handled in w_object() in marshal.c - | type[StopIteration] | types.EllipsisType | bool | None + | type[StopIteration] + | types.EllipsisType + | bool + | None ) if sys.version_info >= (3, 15): diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 427aaa8c0494..77f73cc7619c 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -539,11 +539,7 @@ class _Screen(TurtleScreen): def __init__(self) -> None: ... # Note int and float are interpreted differently def setup( - self, - width: int | float = 0.5, - height: int | float = 0.75, - startx: int | None = None, - starty: int | None = None, + self, width: int | float = 0.5, height: int | float = 0.75, startx: int | None = None, starty: int | None = None ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... From 2b20b97afcd4eeaa5314711ce7446d530f17d078 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 13 Nov 2026 16:24:04 +0100 Subject: [PATCH 3/3] Fix a few overload warnings --- stdlib/builtins.pyi | 8 ++++---- stdlib/fractions.pyi | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 730081a62e8f..c3bcb182f77f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -2176,17 +2176,17 @@ def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ... @overload def pow(base: int, exp: int, mod: None = None) -> Any: ... @overload -def pow(base: _PositiveInteger, exp: FloatInt, mod: None = None) -> float: ... +def pow(base: _PositiveInteger, exp: float, mod: None = None) -> float: ... @overload -def pow(base: _NegativeInteger, exp: FloatInt, mod: None = None) -> complex: ... +def pow(base: _NegativeInteger, exp: float, mod: None = None) -> complex: ... @overload -def pow(base: FloatInt, exp: int, mod: None = None) -> float: ... +def pow(base: float, exp: int, mod: None = None) -> float: ... # float base & float exp could return float or complex # return type must be Any (same as complex base, complex exp), # as `float | complex` causes too many false-positive errors @overload -def pow(base: FloatInt, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> Any: ... +def pow(base: float, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> Any: ... @overload def pow(base: complex, exp: complex | float | int | _SupportsSomeKindOfPow, mod: None = None) -> complex: ... @overload diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index bf07da84775a..928ce93bf86b 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -42,101 +42,101 @@ class Fraction(Rational): @overload def __add__(a, b: int | Fraction) -> Fraction: ... @overload - def __add__(a, b: FloatInt) -> float: ... + def __add__(a, b: float) -> float: ... @overload def __add__(a, b: complex) -> complex: ... @overload def __radd__(b, a: int | Fraction) -> Fraction: ... @overload - def __radd__(b, a: FloatInt) -> float: ... + def __radd__(b, a: float) -> float: ... @overload def __radd__(b, a: complex) -> complex: ... @overload def __sub__(a, b: int | Fraction) -> Fraction: ... @overload - def __sub__(a, b: FloatInt) -> float: ... + def __sub__(a, b: float) -> float: ... @overload def __sub__(a, b: complex) -> complex: ... @overload def __rsub__(b, a: int | Fraction) -> Fraction: ... @overload - def __rsub__(b, a: FloatInt) -> float: ... + def __rsub__(b, a: float) -> float: ... @overload def __rsub__(b, a: complex) -> complex: ... @overload def __mul__(a, b: int | Fraction) -> Fraction: ... @overload - def __mul__(a, b: FloatInt) -> float: ... + def __mul__(a, b: float) -> float: ... @overload def __mul__(a, b: complex) -> complex: ... @overload def __rmul__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmul__(b, a: FloatInt) -> float: ... + def __rmul__(b, a: float) -> float: ... @overload def __rmul__(b, a: complex) -> complex: ... @overload def __truediv__(a, b: int | Fraction) -> Fraction: ... @overload - def __truediv__(a, b: FloatInt) -> float: ... + def __truediv__(a, b: float) -> float: ... @overload def __truediv__(a, b: complex) -> complex: ... @overload def __rtruediv__(b, a: int | Fraction) -> Fraction: ... @overload - def __rtruediv__(b, a: FloatInt) -> float: ... + def __rtruediv__(b, a: float) -> float: ... @overload def __rtruediv__(b, a: complex) -> complex: ... @overload def __floordiv__(a, b: int | Fraction) -> int: ... @overload - def __floordiv__(a, b: FloatInt) -> float: ... + def __floordiv__(a, b: float) -> float: ... @overload def __rfloordiv__(b, a: int | Fraction) -> int: ... @overload - def __rfloordiv__(b, a: FloatInt) -> float: ... + def __rfloordiv__(b, a: float) -> float: ... @overload def __mod__(a, b: int | Fraction) -> Fraction: ... @overload - def __mod__(a, b: FloatInt) -> float: ... + def __mod__(a, b: float) -> float: ... @overload def __rmod__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmod__(b, a: FloatInt) -> float: ... + def __rmod__(b, a: float) -> float: ... @overload def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __divmod__(a, b: FloatInt) -> tuple[float, Fraction]: ... + def __divmod__(a, b: float) -> tuple[float, Fraction]: ... @overload def __rdivmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __rdivmod__(a, b: FloatInt) -> tuple[float, Fraction]: ... + def __rdivmod__(a, b: float) -> tuple[float, Fraction]: ... if sys.version_info >= (3, 14): @overload def __pow__(a, b: int, modulo: None = None) -> Fraction: ... @overload - def __pow__(a, b: FloatInt | Fraction, modulo: None = None) -> float: ... + def __pow__(a, b: float | Fraction, modulo: None = None) -> float: ... @overload def __pow__(a, b: complex, modulo: None = None) -> complex: ... else: @overload def __pow__(a, b: int) -> Fraction: ... @overload - def __pow__(a, b: FloatInt | Fraction) -> float: ... + def __pow__(a, b: float | Fraction) -> float: ... @overload def __pow__(a, b: complex) -> complex: ...