Skip to content

Commit 8c10dd0

Browse files
committed
Add a test to fine-grained
1 parent 43dd091 commit 8c10dd0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test-data/unit/fine-grained.test

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,6 +3705,34 @@ def foo() -> None:
37053705
==
37063706
b.py:4: error: Incompatible types in assignment (expression has type "str", variable has type "int")
37073707

3708+
[case testTypedDictUpdateReadOnly]
3709+
import b
3710+
[file a.py]
3711+
from typing_extensions import TypedDict, ReadOnly
3712+
Point = TypedDict('Point', {'x': int, 'y': int})
3713+
p = Point(x=1, y=2)
3714+
[file a.py.2]
3715+
from typing_extensions import TypedDict, ReadOnly
3716+
class Point(TypedDict):
3717+
x: int
3718+
y: ReadOnly[int]
3719+
p = Point(x=1, y=2)
3720+
[file a.py.3]
3721+
from typing_extensions import TypedDict, ReadOnly
3722+
Point = TypedDict('Point', {'x': ReadOnly[int], 'y': int})
3723+
p = Point(x=1, y=2)
3724+
[file b.py]
3725+
from a import Point
3726+
def foo(x: Point) -> None:
3727+
x['x'] = 1
3728+
x['y'] = 2
3729+
[builtins fixtures/dict.pyi]
3730+
[out]
3731+
==
3732+
b.py:4: error: ReadOnly TypedDict key "y" TypedDict is mutated
3733+
==
3734+
b.py:3: error: ReadOnly TypedDict key "x" TypedDict is mutated
3735+
37083736
[case testBasicAliasUpdate]
37093737
import b
37103738
[file a.py]

0 commit comments

Comments
 (0)