diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index e3965fab0..99f5c8d2a 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -5,6 +5,7 @@ from _typeshed import ProfileFunction, TraceFunction from collections.abc import Callable, Iterable, Mapping from types import TracebackType from typing import Any, TypeVar, final +from typing_extensions import deprecated _T = TypeVar("_T") @@ -44,9 +45,11 @@ if sys.version_info >= (3, 12): _profile_hook: ProfileFunction | None def active_count() -> int: ... -def activeCount() -> int: ... # deprecated alias for active_count() +@deprecated("Use active_count() instead") +def activeCount() -> int: ... def current_thread() -> Thread: ... -def currentThread() -> Thread: ... # deprecated alias for current_thread() +@deprecated("Use current_thread() instead") +def currentThread() -> Thread: ... def get_ident() -> int: ... def enumerate() -> list[Thread]: ... def main_thread() -> Thread: ... @@ -89,11 +92,14 @@ class Thread: @property def native_id(self) -> int | None: ... # only available on some platforms def is_alive(self) -> bool: ... - # the following methods are all deprecated - def getName(self) -> str: ... - def setName(self, name: str) -> None: ... + @deprecated("Get the daemon attribute instead") def isDaemon(self) -> bool: ... + @deprecated("Set the daemon attribute instead") def setDaemon(self, daemonic: bool) -> None: ... + @deprecated("Use the name attribute instead") + def getName(self) -> str: ... + @deprecated("Use the name attribute instead") + def setName(self, name: str) -> None: ... class _DummyThread(Thread): def __init__(self) -> None: ... @@ -124,7 +130,8 @@ class Condition: def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ... def notify(self, n: int = 1) -> None: ... def notify_all(self) -> None: ... - def notifyAll(self) -> None: ... # deprecated alias for notify_all() + @deprecated("Use notify_all() instead") + def notifyAll(self) -> None: ... class Semaphore: _value: int @@ -138,7 +145,8 @@ class BoundedSemaphore(Semaphore): ... class Event: def is_set(self) -> bool: ... - def isSet(self) -> bool: ... # deprecated alias for is_set() + @deprecated("Use is_set() instead") + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: float | None = None) -> bool: ...