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

Failing to concatenate fix lengths tuples if the tuple depends on a variable #8416

Closed
knatten opened this issue Feb 18, 2020 · 4 comments
Closed

Comments

@knatten
Copy link

knatten commented Feb 18, 2020

I believe this is a bug. Reproduced with mypy 0.761 on Ubuntu 18.04.

In this code:

def breaks(self) -> None:
    var = True
    t = ("a","b") + (("c","d") if var else tuple())

def works(self) -> None:
    t = ("a","b") + (("c","d") if True else tuple())

The works function works fine, but the breaks function breaks with the following error:

$ mypy tuple_if.py 
tuple_if.py:3: error: No overload variant of "__add__" of "tuple" matches argument type "object"
tuple_if.py:3: note: Possible overload variants:
tuple_if.py:3: note:     def __add__(self, Tuple[str, ...]) -> Tuple[str, ...]
tuple_if.py:3: note:     def __add__(self, Tuple[Any, ...]) -> Tuple[Any, ...]
Found 1 error in 1 file (checked 1 source file)

I would expect the behaviour to be the same in both functions.

@intgr
Copy link
Contributor

intgr commented Feb 18, 2020

Hi! I think this is a duplicate of #4975 and is fixed by #8333 (already merged). It hasn't been released though, if you're feeling adventurous you could try reproducing this with the master branch.

@JukkaL JukkaL closed this as completed Feb 20, 2020
@knatten
Copy link
Author

knatten commented Feb 21, 2020

@JukkaL since you closed this issue, did you test whether this is fixed on master?

@intgr
Copy link
Contributor

intgr commented Feb 21, 2020

✅ I tested it now, result was: Success: no issues found in 1 source file

@knatten
Copy link
Author

knatten commented Feb 24, 2020

Nice, thanks for testing!

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

No branches or pull requests

3 participants