Skip to content

When strict optional is disabled, anything can be falsey #6876

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

Merged
merged 2 commits into from
May 22, 2019

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 21, 2019

Previously some code was treated incorrectly as unreachable, since
some checks where treated as always true even though they could
be false given a None value.

Fixes #3601.

Previously some code was treated incorrectly as unreachable, since
some checks where treated as always true even though they could
be false given a None value.

Fixes #6827.
@JukkaL JukkaL requested a review from ilevkivskyi May 21, 2019 16:11
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (modulo a possible typo in test).

Also are you sure you are mentioning the right issue in the PR description? The issue mentioned is already closed (as a duplicate).

if not a:
1() # E: "int" not callable
b = (1, 2)
if not a:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be b here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@JukkaL
Copy link
Collaborator Author

JukkaL commented May 22, 2019

Update the target issue; it was pointing to an obsolete duplicate.

@JukkaL JukkaL merged commit 14dc4b6 into master May 22, 2019
@JelleZijlstra JelleZijlstra deleted the tuple-false-negative branch May 22, 2019 14:50
PattenR pushed a commit to PattenR/mypy that referenced this pull request Jun 23, 2019
Previously some code was treated incorrectly as unreachable, since
some checks where treated as always true even though they could
be false given a None value.

Fixes python#3601.
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

Successfully merging this pull request may close these issues.

Optional[NamedTuple] makes mypy think a branch is unreachable
2 participants