Skip to content

Commit 10b4c62

Browse files
authored
Properly mark deprecated methods in threading (#13861)
1 parent fec4a10 commit 10b4c62

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

stdlib/threading.pyi

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from _typeshed import ProfileFunction, TraceFunction
55
from collections.abc import Callable, Iterable, Mapping
66
from types import TracebackType
77
from typing import Any, TypeVar, final
8+
from typing_extensions import deprecated
89

910
_T = TypeVar("_T")
1011

@@ -44,9 +45,11 @@ if sys.version_info >= (3, 12):
4445
_profile_hook: ProfileFunction | None
4546

4647
def active_count() -> int: ...
47-
def activeCount() -> int: ... # deprecated alias for active_count()
48+
@deprecated("Use active_count() instead")
49+
def activeCount() -> int: ...
4850
def current_thread() -> Thread: ...
49-
def currentThread() -> Thread: ... # deprecated alias for current_thread()
51+
@deprecated("Use current_thread() instead")
52+
def currentThread() -> Thread: ...
5053
def get_ident() -> int: ...
5154
def enumerate() -> list[Thread]: ...
5255
def main_thread() -> Thread: ...
@@ -89,11 +92,14 @@ class Thread:
8992
@property
9093
def native_id(self) -> int | None: ... # only available on some platforms
9194
def is_alive(self) -> bool: ...
92-
# the following methods are all deprecated
93-
def getName(self) -> str: ...
94-
def setName(self, name: str) -> None: ...
95+
@deprecated("Get the daemon attribute instead")
9596
def isDaemon(self) -> bool: ...
97+
@deprecated("Set the daemon attribute instead")
9698
def setDaemon(self, daemonic: bool) -> None: ...
99+
@deprecated("Use the name attribute instead")
100+
def getName(self) -> str: ...
101+
@deprecated("Use the name attribute instead")
102+
def setName(self, name: str) -> None: ...
97103

98104
class _DummyThread(Thread):
99105
def __init__(self) -> None: ...
@@ -124,7 +130,8 @@ class Condition:
124130
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
125131
def notify(self, n: int = 1) -> None: ...
126132
def notify_all(self) -> None: ...
127-
def notifyAll(self) -> None: ... # deprecated alias for notify_all()
133+
@deprecated("Use notify_all() instead")
134+
def notifyAll(self) -> None: ...
128135

129136
class Semaphore:
130137
_value: int
@@ -138,7 +145,8 @@ class BoundedSemaphore(Semaphore): ...
138145

139146
class Event:
140147
def is_set(self) -> bool: ...
141-
def isSet(self) -> bool: ... # deprecated alias for is_set()
148+
@deprecated("Use is_set() instead")
149+
def isSet(self) -> bool: ...
142150
def set(self) -> None: ...
143151
def clear(self) -> None: ...
144152
def wait(self, timeout: float | None = None) -> bool: ...

0 commit comments

Comments
 (0)