Skip to content

Commit

Permalink
added __bool__ to object.
Browse files Browse the repository at this point in the history
  • Loading branch information
randolf-scholz committed Aug 21, 2024
1 parent 0246c59 commit 3faf17c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ MaybeNone: TypeAlias = Any # stable
sentinel: Any

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

# stable
Expand Down
1 change: 1 addition & 0 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class object:
def __class__(self, type: type[object], /) -> None: ...
def __init__(self) -> None: ...
def __new__(cls) -> Self: ...
def __bool__(self) -> bool: ...
# N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers.
# Overriding them in subclasses has different semantics, even if the override has an identical signature.
def __setattr__(self, name: str, value: Any, /) -> None: ...
Expand Down

0 comments on commit 3faf17c

Please sign in to comment.