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

The annotation inserted on double-click of the preview of inferred type does not match, and instead inserts the first imported variable of that type #5693

Closed
Raptor-Powered opened this issue Mar 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@Raptor-Powered
Copy link

Environment data

  • Language Server version: 2024.3.101, also appears in 2024.3.2

  • OS and version: Windows 10

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.3

  • VSCode extensions enabled: Python, Python Debugger, Pylance

Code Snippet

The simplest case.

from math import pi

def foo(a: float):
    z = a
    return z

A case with multiple types.

from math import pi, tau
from sys import dllhandle


def foo(a: float, b: int, c: float):
    x = a + pi * dllhandle * tau * 0
    y = c
    z = b
    return x, y, z

Repro Steps

  1. Double click on ": float" when the "Double-click to insert" bubble appears.
  2. ": pi" is inserted instead.

Animation

Expected behavior

The text inserted should match the type inference preview.

Actual behavior

The text inserted is the first imported variable of the type matching the inferred annotation. In my testing this happens with "int" if you use an int variable import (from sys import dllhandle). This also happens whether the variables are used in the module or not. When there are more than one imports of a type only the first is inserted as a type annotation for that type.

Animation1

Logs

This is what is produced when I click ": float" and it turns into ": pi". If more would help I can try to sanitize a full log.

2024-03-26 16:01:39.063 [info] (77556) [BG(1)] InlayHints range 0:0 - 6:0 at file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py ...
2024-03-26 16:01:39.063 [info] (77556) [BG(1)]   parsing: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (0ms)
2024-03-26 16:01:39.063 [info] (77556) [BG(1)]   binding: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (0ms)
2024-03-26 16:01:39.067 [info] (77556) [BG(1)] InlayHints range 0:0 - 6:0 at file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (5ms)
2024-03-26 16:01:39.312 [info] (77556) [BG(1)] analyzing: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py ...
2024-03-26 16:01:39.313 [info] (77556) [BG(1)]   checking: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (5ms)
2024-03-26 16:01:39.313 [info] (77556) [BG(1)] analyzing: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (5ms)
2024-03-26 16:01:39.315 [info] (77556) [FG] parsing: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (1ms)
2024-03-26 16:01:39.315 [info] (77556) [FG] binding: file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (0ms)
2024-03-26 16:01:39.331 [info] (77556) [BG(1)] SemanticTokens delta previousResultId:1711494089709 at file:///c%3A/Users/myuid/Documents/...longfilepathtomyworkspace.../testbug_min.py (0ms)
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Mar 26, 2024
@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Mar 26, 2024
@debonte debonte added fixed in next version (main) A fix has been implemented and will appear in an upcoming version fixed in next version (main) and removed fixed in next version (main) A fix has been implemented and will appear in an upcoming version labels Apr 3, 2024
@debonte
Copy link
Contributor

debonte commented Apr 4, 2024

This issue has been fixed in prerelease version 2024.4.100, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

2 participants