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

Dataclass support doesn't fully resolve ClassVar annotation #876

Closed
abelcheung opened this issue Jan 24, 2021 · 2 comments
Closed

Dataclass support doesn't fully resolve ClassVar annotation #876

abelcheung opened this issue Jan 24, 2021 · 2 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@abelcheung
Copy link

Environment data

  • Language Server version: 2021.1.3-pre.1, 2021.1.2, and possibly earlier versions affected as well
  • OS and version: Windows 7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.2

Issue

Pylance complains with following sample code, with type checking mode set to basic or strict:

import typing
from dataclasses import dataclass

@dataclass
class FooBar:

    attr1: int = 1
    attr2: typing.ClassVar[str]

Screenshot here:

Type checking warning

The warning persists when ClassVar is imported under any alias, like ClassV, typing.ClassVar, whatever.ClassVar. The warning only goes away if I use the exact word ClassVar in annotation. That is replacing first and last line in above sample code with:

from typing import ClassVar
    attr2: ClassVar[str]
@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Jan 24, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.1.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202113-27-january-2021

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

3 participants