Skip to content

Commit 972bad2

Browse files
authored
Add regression test for typing_extensions.Literal and mypy_extensions.TypedDict (#18694)
#18640 removed almost all instances of `typing_extensions.Literal` in the tests. Re-add a simple regression test. Similarly at least one test case should import `mypy_extensions.TypedDict`.
1 parent f1a73cf commit 972bad2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

test-data/unit/check-literal.test

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ y: Literal[43]
5252
y = 43
5353
[typing fixtures/typing-medium.pyi]
5454

55+
[case testLiteralFromTypingExtensionsWorks]
56+
from typing_extensions import Literal
57+
58+
x: Literal[42]
59+
x = 43 # E: Incompatible types in assignment (expression has type "Literal[43]", variable has type "Literal[42]")
60+
61+
y: Literal[43]
62+
y = 43
63+
[builtins fixtures/tuple.pyi]
64+
5565
[case testLiteralInsideOtherTypes]
5666
from typing import Literal, Tuple
5767

test-data/unit/check-typeddict.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -3791,7 +3791,7 @@ x.update({"key": "abc"}) # E: ReadOnly TypedDict key "key" TypedDict is mutated
37913791
[typing fixtures/typing-typeddict.pyi]
37923792

37933793
[case testTypedDictFromMypyExtensionsReadOnlyMutateMethods]
3794-
from typing import TypedDict
3794+
from mypy_extensions import TypedDict
37953795
from typing_extensions import ReadOnly
37963796

37973797
class TP(TypedDict):
@@ -4120,7 +4120,7 @@ Func = TypedDict('Func', {
41204120
[typing fixtures/typing-typeddict.pyi]
41214121

41224122
[case testTypedDictNestedInClassAndInherited]
4123-
from typing_extensions import TypedDict
4123+
from typing import TypedDict
41244124

41254125
class Base:
41264126
class Params(TypedDict):

0 commit comments

Comments
 (0)