Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default parameters for arguments of generic type do not typecheck #4261

Closed
rkr-at-dbx opened this issue Nov 17, 2017 · 1 comment
Closed

Comments

@rkr-at-dbx
Copy link

In the following example, the marked line does not typecheck:

from typing import Generic, TypeVar

_U = TypeVar('_U')

class Thing(Generic[_U]):
    def __init__(self, u):
        # type: (_U) -> None
        pass

def foo(param=3):
    # type: (_U) -> Thing[_U]
    return Thing(param)  # <--

This results in:
error: Incompatible default for argument "param" (default has type "int", argument has type "_U"), even though int is a valid value for _U.

@ilevkivskyi
Copy link
Member

Duplicate of #3737.

(#4236 is also related).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants