Pyright: `Final` not allowed in the context of dataclasses.

Created on 22 Jun 2020  路  4Comments  路  Source: microsoft/pyright

Describe the bug
Final not allowed in the context of dataclasses.

To Reproduce
Steps to reproduce the behavior.

Consider this piece of code

from dataclasses import dataclass
from typing import Final


@dataclass
class Foo:
    bar: Final[str] = "G.R. Emlin"

Hovering over the Final[str] produces an error:

"Final" is not allowed in this context

Expected behavior
Final shouldn't be labeled as not allowed in this context

Additional context

  • VS Code extension: - 1.1.44

    • settings:

      json { "pyright.typeCheckingMode": "strict", "pyright.useLibraryCodeForTypes": true }

  • Python: 3.8.3
addressed in next version bug

All 4 comments

Thanks for the bug report. This will be fixed in the next version of Pyright.

This is now fixed in version 1.1.45, which I just published.

@erictraut Thank you!
Btw, could you link a commit with the bug fix so I could see the actual implementation? :pray:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Afsarsoft picture Afsarsoft  路  3Comments

mmicu picture mmicu  路  3Comments

dbrattli picture dbrattli  路  3Comments

benjaminsaljooghi picture benjaminsaljooghi  路  3Comments

christopher-hesse picture christopher-hesse  路  3Comments