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

--strict-equality should work with literal types #6672

ilevkivskyi opened this issue Apr 14, 2019 · 0 comments · Fixed by #7310


Copy link

@ilevkivskyi ilevkivskyi commented Apr 14, 2019

This example should give an error with --strict-equality:

def returns_a_or_b() -> Literal['a', 'b']:

if returns_a_or_b() == 'c':  # This can never by True

this depends on the implementation of type narrowing by equality checks, see #5935. Basically, Literal[...].__eq__() should provide a literal context for its argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.