Feature
Using a method as a property is a common bug that can be detected by a type checker:
I'd like to introduce a way to enable a check like truthy-bool (#10666) but limited to callable types.
Pitch
Users users might be hesitant to enable truthy-bool due to false positives. For callable types, there's a much higher degree of confidence that evaluating a callable as a boolean is unintentional.
- The error message should be specific, e.g.
- error: Member "my_method" has type "function" which does not implement __bool__ or __len__ so it could always be true in boolean context
+ error: Member "my_method" is a method (are you trying to use it as a property?)
(happy to wordsmith this more, only trying to illustrate that I want it to be friendlier and more actionable)
- The feature could be a separate error-code (thus splitting "callable evaluated in boolean context" from
truthy-bool), or perhaps a way to configure truthy-bool to have a reduced scope? (Is there a common idiom for that?)
Feature
Using a method as a property is a common bug that can be detected by a type checker:
I'd like to introduce a way to enable a check like
truthy-bool(#10666) but limited to callable types.Pitch
Users users might be hesitant to enable
truthy-booldue to false positives. For callable types, there's a much higher degree of confidence that evaluating a callable as a boolean is unintentional.truthy-bool), or perhaps a way to configuretruthy-boolto have a reduced scope? (Is there a common idiom for that?)