Support bare Callable types #670

Closed
Dedoig opened this Issue May 13, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@Dedoig

Dedoig commented May 13, 2015

from typing import Iterable, TypeVar, Callable, Iterator, Generic

T = TypeVar("T")

def gen(f: Callable, *args) -> Callable[[], Iterator[T]]:
    return lambda: f(*args)

Related question: is it currently possible to type argument f: Callable[..., Iterator[T]]?

@JukkaL JukkaL added the bug label May 14, 2015

@JukkaL

This comment has been minimized.

Show comment
Hide comment
@JukkaL

JukkaL May 14, 2015

Collaborator

Hmm, I don't think that PEP 484 says that Callable is a valid type, but mypy shouldn't crash when you try to use it. It should give an error.

Answer to the question: not yet, but it will become possible: #393

Collaborator

JukkaL commented May 14, 2015

Hmm, I don't think that PEP 484 says that Callable is a valid type, but mypy shouldn't crash when you try to use it. It should give an error.

Answer to the question: not yet, but it will become possible: #393

@JukkaL JukkaL added the topic-pep-484 label Jun 1, 2015

@JukkaL

This comment has been minimized.

Show comment
Hide comment
@JukkaL

JukkaL Jun 1, 2015

Collaborator

PEP 484 actually supports using Callable as a type, so mypy should support as well.

Collaborator

JukkaL commented Jun 1, 2015

PEP 484 actually supports using Callable as a type, so mypy should support as well.

@JukkaL JukkaL added the priority label Jun 1, 2015

@JukkaL JukkaL changed the title from This code raises an exception on type-check to Support bare Callable types Jun 1, 2015

@JukkaL

This comment has been minimized.

Show comment
Hide comment
@JukkaL

JukkaL Jun 1, 2015

Collaborator

Callable should be equivalent to Callable[..., Any].

Collaborator

JukkaL commented Jun 1, 2015

Callable should be equivalent to Callable[..., Any].

@ddfisher ddfisher added this to the 0.3.2 milestone Mar 2, 2016

@gnprice gnprice removed the priority label Mar 2, 2016

@ddfisher ddfisher self-assigned this Mar 2, 2016

ddfisher added a commit to ddfisher/mypy that referenced this issue Mar 4, 2016

@gvanrossum gvanrossum closed this in #1273 Mar 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment