-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Tuple slice by variable results in incorrect type #7056
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
Comments
this is of course reduced from a larger program to a minimal reproduction |
I checked and you can accomplish this with
or if you prefer, a |
in reality, sz is not a literal -- it's used in the following way: ver = tuple(int(p) for p in x.split('.'))
sz = len(ver)
return min_ver[:sz] <= ver <= max_ver[:sz] however this is lost when converting to a minimal testcase Here's the current code with the |
Ah, you are correct, sorry I misunderstood the issue. E: also it seems the same does not happen for lists, so this is a bug in tuple handling code. |
It seems the changes in #3514 made the incorrect decision to return the union of elements when given a slice. I'm working on a fix. |
This fixes #7056. The idea is that we don't know what types a tuple slice will result in, other than a tuple of some sort. For example, `(1,'', 3.3)[:a]` could result in `Tuple[()]`, `Tuple[int]`, `Tuple[int, str]`, or `Tuple[int, str, float]`.
👏👏👏 awesome! thanks for the quick fix on this one 🎉 |
The text was updated successfully, but these errors were encountered: