Skip to content

Commit 3faf17c

Browse files
added __bool__ to object.
1 parent 0246c59 commit 3faf17c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

stdlib/_typeshed/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ MaybeNone: TypeAlias = Any # stable
7171
sentinel: Any
7272

7373
class SupportsBool(Protocol):
74+
# NOTE: Since object is a subtype of SupportsBool, this protocol is redundant.
75+
# However, it is kept for clarity, as comparisons are generally expected
76+
# to return boolean-like values.
7477
def __bool__(self) -> bool: ...
7578

7679
# stable

stdlib/builtins.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class object:
105105
def __class__(self, type: type[object], /) -> None: ...
106106
def __init__(self) -> None: ...
107107
def __new__(cls) -> Self: ...
108+
def __bool__(self) -> bool: ...
108109
# N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers.
109110
# Overriding them in subclasses has different semantics, even if the override has an identical signature.
110111
def __setattr__(self, name: str, value: Any, /) -> None: ...

0 commit comments

Comments
 (0)