microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 769 forks source link

Pylance 2022.6.10 no longer allows Enum with another mixed-in type #2930

Closed mikeyk closed 2 years ago

mikeyk commented 2 years ago

Environment data

Code Snippet

from enum import Enum

class StrEnum(str, Enum):
  HELLO = "hello"
  OK = "ok"

Note that this is the order suggested by the Python docs.

Expected behavior

No pylance warning given for snippet above.

Actual behavior

As of the 2022.6.10 release, this now reports:

The metaclass of a derived class must be a subclass of the metaclasses of all its base classes

2022.6.11 pre-release exhibits the same issue. This previously worked in 2022.6.0.

erictraut commented 2 years ago

I'm not able to repro the problem, and I can't think of any reason why this behavior would have changed recently.

Is it possible that you have a custom enum module or stub installed? If you right click on Enum and choose "Go to Declaration", where does it take you?

mikeyk commented 2 years ago

Ah, that was exactly it @erictraut; our local version of typeshed had worked until the latest Pylance update and then the combination started showing that metaclass error; updating typeshed definitions fixes the issue on latest Pylance. Thank you!