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

Dict Key Literal Autocompletion does not work with Attributes #3687

Closed
JakobDev opened this issue Nov 29, 2022 · 3 comments
Closed

Dict Key Literal Autocompletion does not work with Attributes #3687

JakobDev opened this issue Nov 29, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@JakobDev
Copy link

Environment data

  • Language Server version: v2022.11.30
  • OS and version: Windows 10
  • Python version: 3.10.0

Code Snippet

from typing import Literal


test_literal = Literal[
    "Hello", 
    "World",
    "Test",
    "123"
]


a: dict[test_literal, str] = {}
# a[] Autocompletion of Keys works


def test_func() -> dict[test_literal, str]:
    pass


b = test_func()
# b[] Autocompletion of Keys works


class TestClass:
    def __init__(self) -> None:
        self.test_dict = dict[test_literal, str]

        # self.test_dict[] Autocompletion of Keys does not work


c = TestClass()
# c.test_dict[] Autocompletion of Keys does not work

Repro Steps

Copy this code and start typing, where the comments are e.g. a[]. If you do this, the Autocompletion will pop-up and will provide Autocompletion for the Keys. ("Hello, World, Test, 123).

Expected behavior

It should work everywhere

Actual behavior

The autocompletion works only with a and b., but not with self.test_dict and c.test_dict.

Logs

Logs have nothing to do with this

@debonte
Copy link
Contributor

debonte commented Nov 29, 2022

One issue is that self.test_dict, as written, is a type alias.

However, even if I change the declaration of test_dict to one of the following, and Pylance understands that it is of type dict[test_literal, str], I still don't see the expected suggestions:

self.test_dict = dict[test_literal, str]()
self.test_dict: dict[test_literal, str] = {}

@bschnurr bschnurr added the bug Something isn't working label Nov 29, 2022
@bschnurr bschnurr added enhancement New feature or request and removed bug Something isn't working labels Nov 29, 2022
@bschnurr
Copy link
Member

Currently we only support a limited number of cases.

This would be an enhancement.
Thank you

@heejaechang heejaechang self-assigned this Nov 29, 2022
@heejaechang heejaechang added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 29, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Nov 30, 2022

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

@rchiodo rchiodo closed this as completed Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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

5 participants