Is your feature request related to a problem? Please describe.
Currently objects which are marked as returning Literal[False/True] do not actually have their return types used for reachabilty analysis, there is also no way to get the return type using bool(x) which should act an alias for x.__bool__() (or maybe type(x).__bool__(x) if you'd prefer 😉)
Describe the solution you'd like
I'd like to have the return of __bool__ be used for type checking and also have bool() call the methods bool to get the return type and not just have it be bool when it could be more specific.
Additional context
MyPy is implementing a similar feature and I've found it very successful at finding bugs python/mypy#15645
Is your feature request related to a problem? Please describe.
Currently objects which are marked as returning Literal[False/True] do not actually have their return types used for reachabilty analysis, there is also no way to get the return type using
bool(x)which should act an alias forx.__bool__()(or maybetype(x).__bool__(x)if you'd prefer 😉)Describe the solution you'd like
I'd like to have the return of
__bool__be used for type checking and also havebool()call the methods bool to get the return type and not just have it beboolwhen it could be more specific.Additional context
MyPy is implementing a similar feature and I've found it very successful at finding bugs python/mypy#15645