I think adding this kind of logic with if callable(x): has come up before in this issue tracker. It should be easy to do (with the provision that mypy currently only understands that Callable things are callable, but not in general instances with __call__ methods; but that should be sufficient in your example).
I think adding this kind of logic with if callable(x): has come up before
in this issue tracker. It should be easy to do (with the provision that
mypy currently only understands that Callable things are callable, but
not in general instances with call methods; but that should be
sufficient in your example).
Activity
sametmax commented on Oct 14, 2016
If there the same fix with if callable()? Because I got this:
def __getitem__(self, index): # type: (Union[int, slice, Callable]) -> Union[IterableWrapper, Any] if isinstance(index, int): return at_index(self.iterator, index) if callable(index): return first_true(self.iterator, index) start = index.start or 0 step = index.step or 1 stop = index.stopAnd mypy complains that index may not have a start attribute.
rwbarton commented on Oct 14, 2016
I think adding this kind of logic with if callable(x): has come up before in this issue tracker. It should be easy to do (with the provision that mypy currently only understands that Callable things are callable, but not in general instances with __call__ methods; but that should be sufficient in your example).
gvanrossum commented on Oct 14, 2016
Yeah, adding callable() is #1973. Better support for __call__ is #797.
On Fri, Oct 14, 2016 at 5:53 AM, Reid Barton notifications@github.com
wrote:
--Guido van Rossum (python.org/~guido)