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

Mypy allows assigning a union to a variable with type Type[...] #3693

Closed
ilevkivskyi opened this issue Jul 11, 2017 · 2 comments
Closed

Mypy allows assigning a union to a variable with type Type[...] #3693

ilevkivskyi opened this issue Jul 11, 2017 · 2 comments

Comments

@ilevkivskyi
Copy link
Member

Mypy allows this:

x: Type[object] = Union[int, str]

although it is explicitly prohibited by PEP 484. (The reason is that one can't instantiate a union.)

@AlexWaygood
Copy link
Member

Mypy now emits an error for this snippet:

from typing import *
x: Type[object] = Union[int, str]  # error: Incompatible types in assignment (expression has type "object", variable has type "Type[object]")

Can this now be closed?

@erictraut
Copy link

Yes, this appears to generate the proper error now.

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

No branches or pull requests

3 participants