0

I'm using pylance on VScode for type checking my Python code. It is having trouble with the frozen argument of dataclasses:

from dataclasses import dataclass

@dataclass(frozen=True)
class DataStoreConfig():
  store_id: str
  bucket_name: str
  prefix: str

Pylance complains with this error: "frozen" is not definedPylance (reportUndefinedVariable)

When I navigate to dataclasses.pyi, this is what I see for dataclass:

@overload
def dataclass(_cls: Type[_T]) -> Type[_T]: ...
@overload
def dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]: ...
@overload
def dataclass(
    *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ...
) -> Callable[[Type[_T]], Type[_T]]: ...

So it seems like it is not picking the right overloaded method. Anyway to guide it?

MattDMo
  • 100,794
  • 21
  • 241
  • 231
AHonarmand
  • 530
  • 1
  • 8
  • 16
  • Please don't tag your IDE or code editor unless your question is specifically related to the editor itself. – MattDMo Sep 08 '20 at 17:22
  • 1
    This issue is reported here: https://github.com/microsoft/pylance-release/issues/322. They are working on a fix. – AHonarmand Sep 08 '20 at 17:35

0 Answers0