Skip to content

Bug with inline if-else and tuples #5649

New issue

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

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

Already on GitHub? # to your account

Closed
gregdingle opened this issue Sep 19, 2018 · 2 comments
Closed

Bug with inline if-else and tuples #5649

gregdingle opened this issue Sep 19, 2018 · 2 comments

Comments

@gregdingle
Copy link

Thanks for all the work with mypy. I'm really enjoying it every time I code now.

I found this oddity which may be a bug.

Here is a short demo.

from typing import Tuple

def demo() -> Tuple[str, ...]:
    matches = [('a', 'b')]
    return matches[0] if matches else tuple()
    # demo.py:6: error: Incompatible return value type (got "object", expected "Tuple[str, ...]")


def noerror() -> Tuple[str, ...]:
    matches = [('a', 'b')]
    if matches:
        return matches[0]
    else:
        return tuple()
@srittau
Copy link
Contributor

srittau commented Sep 20, 2018

Possibly related to #5392.

@ilevkivskyi
Copy link
Member

This is just a combination of #4975 and #5392. Fixing any of those fill fix this as well.

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

No branches or pull requests

3 participants