-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for a "bare"
Final
annotation in a dataclass entry th…
…at has a default value assigned to it. This addresses #9468.
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/pyright-internal/src/tests/samples/dataclass18.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This sample tests the case where a "bare" Final is used in a dataclass | ||
# with a default value. | ||
|
||
from typing import Final | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class DC1: | ||
a: Final = 1 | ||
|
||
|
||
v1 = DC1(1) | ||
reveal_type(v1.a, expected_text="Literal[1]") | ||
|
||
v2 = DC1() | ||
reveal_type(v2.a, expected_text="Literal[1]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters