Apologies if I'm missing something obvious, but I checked issues and PR's and haven't seen this mentioned explicitly.
Could isinstance use TypeIs?
With multiples checks it could return an union, with one type T a TypeIs[T].
I often find myself writing one-liner helpers functions that just call isinstance, see this script for example:
https://github.com/OutSquareCapital/pyochain/blob/master/scripts/check_docstrings.py
This both add boilerplate and a performance tax due to a double function call overhead.
I'm very often using lambdas with fluent interfaces, e.g
res = (
my_iterator
.map(lambda x: ...)
.filter(lambda x: isinstance(x, int)
)
Assuming my_iterator is an Iterator[Any], it would be fantastic if it could be narrowed to Iterator[int] without having to define a separate TypeIs function.
Apologies if I'm missing something obvious, but I checked issues and PR's and haven't seen this mentioned explicitly.
Could
isinstanceuseTypeIs?With multiples checks it could return an union, with one type
TaTypeIs[T].I often find myself writing one-liner helpers functions that just call isinstance, see this script for example:
https://github.com/OutSquareCapital/pyochain/blob/master/scripts/check_docstrings.py
This both add boilerplate and a performance tax due to a double function call overhead.
I'm very often using lambdas with fluent interfaces, e.g
Assuming
my_iteratoris anIterator[Any], it would be fantastic if it could be narrowed toIterator[int]without having to define a separate TypeIs function.