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

Set[T] is incompatible with Set[Optional[T]] - Set[None] #8526

Open
0az opened this issue Mar 11, 2020 · 2 comments
Open

Set[T] is incompatible with Set[Optional[T]] - Set[None] #8526

0az opened this issue Mar 11, 2020 · 2 comments

Comments

@0az
Copy link

0az commented Mar 11, 2020

Tested with 0.761.

MWE:

from typing import Optional, Set

class Foo:
    pass

bar: Set[Optional[Foo]] = set()
baz: Set[Foo] = bar - {None}
# Incompatible types in assignment (expression has type "Set[Optional[Foo]]",
# variable has type "Set[Foo]")
@PeterJCLaw
Copy link
Contributor

If support for this is added, maybe we could also consider including support for sets of Literal too?
(my use-cases is actually also the None case, but I'm guessing the same logic might work for both)

@PeterJCLaw
Copy link
Contributor

PeterJCLaw commented Apr 25, 2020

Also possibly related - it would be great if mypy could understand the use of set.discard (etc.) to remove None elements.

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