File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ def get_column(self) -> int:
123
123
'typing.DefaultDict' : 'collections.defaultdict' ,
124
124
'typing.Deque' : 'collections.deque' ,
125
125
'typing.OrderedDict' : 'collections.OrderedDict' ,
126
+ 'typing.LiteralString' : 'builtins.str' , # a lie in lieu of actual support for PEP 675
126
127
}
127
128
128
129
# This keeps track of the oldest supported Python version where the corresponding
@@ -137,12 +138,14 @@ def get_column(self) -> int:
137
138
'typing.DefaultDict' : (2 , 7 ),
138
139
'typing.Deque' : (2 , 7 ),
139
140
'typing.OrderedDict' : (3 , 7 ),
141
+ 'typing.LiteralString' : (3 , 11 ),
140
142
}
141
143
142
144
# This keeps track of aliases in `typing_extensions`, which we treat specially.
143
145
typing_extensions_aliases : Final = {
144
146
# See: https://github.com/python/mypy/issues/11528
145
147
'typing_extensions.OrderedDict' : 'collections.OrderedDict' ,
148
+ 'typing_extensions.LiteralString' : 'builtins.str' , # a lie in lieu of actual support for PEP 675
146
149
}
147
150
148
151
reverse_builtin_aliases : Final = {
Original file line number Diff line number Diff line change @@ -752,3 +752,21 @@ from typing_extensions import TypeAlias
752
752
A: TypeAlias = str
753
753
[builtins fixtures/bool.pyi]
754
754
[out]
755
+
756
+
757
+ [case testLiteralStringPep675]
758
+ # flags: --python-version 3.11
759
+ from typing import LiteralString as tpLS
760
+ from typing_extensions import LiteralString as tpxLS
761
+
762
+ def f(a: tpLS, b: tpxLS) -> None:
763
+ reveal_type(a) # N: Revealed type is "builtins.str"
764
+ reveal_type(b) # N: Revealed type is "builtins.str"
765
+
766
+ # This isn't the correct behaviour, but should unblock use of LiteralString in typeshed
767
+ f("asdf", "asdf")
768
+ string: str
769
+ f(string, string)
770
+
771
+ [builtins fixtures/tuple.pyi]
772
+ [typing fixtures/typing-medium.pyi]
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ TypedDict = 0
27
27
NoReturn = 0
28
28
NewType = 0
29
29
TypeAlias = 0
30
+ LiteralString = 0
30
31
31
32
T = TypeVar ('T' )
32
33
T_co = TypeVar ('T_co' , covariant = True )
You can’t perform that action at this time.
0 commit comments