-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
class Foo:
@property
def prop(self) -> bool:
return False
def bools_only(value: bool) -> bool:
return value
bools_only(Foo().prop) # Standard behavior of properties
bools_only(Foo.prop) # Expected type 'bool', got 'property' instead
bools_only(not Foo.prop) # no error after casting with `not`!
Python interprets not object
as not bool(object)
which doesn't seem to be covered by any checks.
Tested with Mypy 1.11.2 and Python 3.12
https://mypy-play.net/?mypy=latest&python=3.12&gist=1c5f3510b686dd0e2e04e0a9ef191a96