Changed callable to return TypeIs[Callable] rather than TypeIs[Callable[..., object]] #16051
Changed callable to return TypeIs[Callable] rather than TypeIs[Callable[..., object]] #16051randolf-scholz wants to merge 5 commits into
TypeIs[Callable] rather than TypeIs[Callable[..., object]] #16051Conversation
This comment has been minimized.
This comment has been minimized.
|
you can fix the pyright issues by using But it's unclear to me why this change is desirable. I don't really agree that type checkers are correct in narrowing an object to |
This comment has been minimized.
This comment has been minimized.
|
Well, I would say there are 2 motivations:
from typing import reveal_type
from collections.abc import Iterable
def check(arg: object) -> None:
if isinstance(arg, Iterable):
reveal_type(arg)
reveal_type(next(iter(arg)))Here all the type checkers, except |
|
Oh, and wrt to the last point, my idea with using |
This comment has been minimized.
This comment has been minimized.
9e78a50 to
39fe412
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Fixes #16050