Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Tuple[int, int] not unpacked correctly into lvar tuple #1457

Closed
bvanrijn opened this issue Aug 19, 2019 · 4 comments · Fixed by #1553
Closed

Tuple[int, int] not unpacked correctly into lvar tuple #1457

bvanrijn opened this issue Aug 19, 2019 · 4 comments · Fixed by #1553
Assignees

Comments

@bvanrijn
Copy link

Description

In the following piece of code, the Microsoft Python Analysis Engine incorrectly infers the types of a and b when hovering over them.

Minimal reproducible example

from typing import Tuple, List

def foo() -> List[Tuple[int, int]]:
    return [(1, -1)]

result = foo()
(a, b) = result[0]

Expected behavior

When hovering over a or b, I expect to see a: int and b: int.

Actual behavior

When hovering over a or b, it shows a: Tuple[int, int] and b: Tuple[int, int]. I also tested this using PyCharm CE and it correctly inferred the types (i.e. a: int and b: int).

System information

OS: macOS "Mojave" 10.14.6 (18G87)

Visual Studio Code

Python extension version: 2019.8.30787

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:16:34.800Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0

@MikhailArkhipov
Copy link

It actually displays type of the tuple correctly: Tuple[int, int] for span of (a, b). What is requested is to make separate hovers over the tuple content so hovering over a and b would display their types.

@MikhailArkhipov MikhailArkhipov changed the title Microsoft Python Analysis Engine does not properly display the types of tuples Hover tooltip should show types of tuple parts rather type of the tuple Aug 19, 2019
@bvanrijn
Copy link
Author

You're right, I should have been more specific.

@jakebailey
Copy link
Member

That's not exactly true; this breaks because of our unpacking logic. Note how a and b are Tuple[int, int], so it's not the hover.

image

@jakebailey jakebailey changed the title Hover tooltip should show types of tuple parts rather type of the tuple Tuple[int, int] not unpacked correctly into lvar tuple Aug 26, 2019
@CTrando CTrando self-assigned this Aug 28, 2019
MikhailArkhipov pushed a commit that referenced this issue Sep 16, 2019
@MikhailArkhipov
Copy link

0.4.18+

jakebailey pushed a commit to jakebailey/python-language-server that referenced this issue Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants