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

Descriptor type shown in autocomplete popover is incorrect #5299

Open
henribru opened this issue Dec 21, 2023 · 2 comments
Open

Descriptor type shown in autocomplete popover is incorrect #5299

henribru opened this issue Dec 21, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@henribru
Copy link

henribru commented Dec 21, 2023

Environment data

  • Language Server version: 2023.12.1
  • OS and version: linux x64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.11.6
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: off

Code Snippet

from typing import overload

class FooIntDescriptor:
    @overload
    def __get__(self, instance: None, type: type["Foo"]) -> "FooIntDescriptor": ...
    @overload
    def __get__(self, instance: "Foo", type: type["Foo"]) -> int: ...
    def __get__(self, instance: "Foo" | None, type: type["Foo"]) -> int | "FooIntDescriptor":
        if instance is None:
            return self
        return 3
    
class Foo:
    foo: FooIntDescriptor
    bar: int

foo = Foo()

Repro Steps

Type
foo.f

and observe the type shown for foo.foo in the autocomplete popup.

Expected behavior

The type for foo.foo is shown as int in the autocomplete popup. If you type it out and then hover over it, this type is correctly shown:
image

Actual behavior

The type for foo.foo is shown as FooIntDescriptor in the autocomplete popup, like if it was looked up on the class instead of the instance:

image

Logs

https://gist.github.com/henribru/7e9997261acd33583f85e6a769a5459e

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 21, 2023
@KacieKK KacieKK added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Mar 6, 2024
@KacieKK
Copy link
Contributor

KacieKK commented Jul 10, 2024

Thanks for this issue, I can repro in 2024.7.1 version.

@whatamithinking
Copy link

This remains an issue as of v2024.12.1. Any updates or known work arounds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants