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

Intellisense still not fully working with Enum classes #4928

Closed
tomhsel opened this issue Oct 5, 2023 · 6 comments
Closed

Intellisense still not fully working with Enum classes #4928

tomhsel opened this issue Oct 5, 2023 · 6 comments
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

@tomhsel
Copy link

tomhsel commented Oct 5, 2023

I believe this may be related to #1905 and #4734.

Environment data

  • Language Server version: 2023.9.30
  • OS and version: Windows 11 build 22621.2283 and Ubuntu 22.04.3 (WSL)
  • Python version (& distribution if applicable, e.g. Anaconda):
    • 3.8.10, 3.9.13, 3.10.11, 3.11.6 (python.org Windows installers)
    • 3.10.12 (through apt on Ubuntu)

Code Snippet

from enum import Enum

class Test(Enum):
    X = "x"

    @property
    def is_x(self) -> bool:
        return True

Repro Steps

  1. Type Test.X.

Expected behavior

The property is_x should be displayed in the suggestions for Test.X.

Actual behavior

Only attributes that are universally applicable to Enum members are displayed (name, value, and the standard sunder/dunder attributes)

Even worse, if the Enum class doesn't inherit directly from enum.Enum, the suggestions popup is empty (or displays No suggestions. if you try to force the matter with Ctrl+Space). This includes Enums that make use of enum.IntEnum or Python 3.11's enum.ReprEnum and enum.StrEnum.

The example from https://docs.python.org/3/howto/enum.html#planet also fails to produce the attributes created in __init__.

It should also be noted that all of these attributes added in each of these various ways are correctly understood by the typing system when used, they are simply missing from the provided suggestions.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Oct 5, 2023
@bschnurr bschnurr removed their assignment Jan 4, 2024
@ion-elgreco
Copy link

I also noticed this; I am adding all kind of methods to our enums but they don't show up in autocomplete 0_o

@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Feb 16, 2024
@debonte
Copy link
Contributor

debonte commented Feb 16, 2024

This bug is a side-effect of changes made for #1905 and #4734. We're still filtering out too many members on enum instances.

@fordneild
Copy link

Hi @heejaechang any updates on this? I think giving enums custom methods is a pretty great pattern that I encourage folks to do, but the lack of intellisense makes this tough. many thanks :)

@heejaechang
Copy link
Contributor

I believe it is already fixed. I think we forgot to mark this as fixed.

image

@Denis-Alexeev
Copy link

Denis-Alexeev commented Jun 25, 2024

@heejaechang @fordneild But it is not working. The problem, that the instance of enum must also have this hint
telegram-cloud-photo-size-2-5465241967882524802-x

@heejaechang heejaechang reopened this Jun 25, 2024
@bschnurr bschnurr added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jun 28, 2024
@heejaechang
Copy link
Contributor

This issue has been fixed in prerelease version 2024.7.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

7 participants