@@ -224,7 +224,7 @@ accepts_bytes(c_alias)
224224[builtins fixtures/tuple.pyi]
225225[out]
226226
227- [case testLiteralMixingUnicodeAndBytesPython3ForwardStrings_no_native_parse ]
227+ [case testLiteralMixingUnicodeAndBytesPython3ForwardStrings ]
228228from typing import Literal, TypeVar, Generic
229229
230230a_unicode_wrapper: u"Literal[u'foo']"
@@ -235,7 +235,7 @@ a_str_wrapper: "Literal[u'foo']"
235235b_str_wrapper: "Literal['foo']"
236236c_str_wrapper: "Literal[b'foo']"
237237
238- # In Python 3, forward references MUST be str, not bytes
238+ # In Python 3, forward references MUST be str, not bytes.
239239a_bytes_wrapper: b"Literal[u'foo']" # E: Invalid type comment or annotation
240240b_bytes_wrapper: b"Literal['foo']" # E: Invalid type comment or annotation
241241c_bytes_wrapper: b"Literal[b'foo']" # E: Invalid type comment or annotation
@@ -265,9 +265,10 @@ a_str_wrapper_alias: AStrWrapperAlias
265265b_str_wrapper_alias: BStrWrapperAlias
266266c_str_wrapper_alias: CStrWrapperAlias
267267
268- ABytesWrapperAlias = Wrap[b"Literal[u'foo']"]
269- BBytesWrapperAlias = Wrap[b"Literal['foo']"]
270- CBytesWrapperAlias = Wrap[b"Literal[b'foo']"]
268+ # Bytes literals are not valid as forward references.
269+ ABytesWrapperAlias = Wrap[b"Literal[u'foo']"] # E: Invalid type comment or annotation
270+ BBytesWrapperAlias = Wrap[b"Literal['foo']"] # E: Invalid type comment or annotation
271+ CBytesWrapperAlias = Wrap[b"Literal[b'foo']"] # E: Invalid type comment or annotation
271272a_bytes_wrapper_alias: ABytesWrapperAlias
272273b_bytes_wrapper_alias: BBytesWrapperAlias
273274c_bytes_wrapper_alias: CBytesWrapperAlias
@@ -282,9 +283,9 @@ reveal_type(a_str_wrapper_alias) # N: Revealed type is "__main__.Wrap[Liter
282283reveal_type(b_str_wrapper_alias) # N: Revealed type is "__main__.Wrap[Literal['foo']]"
283284reveal_type(c_str_wrapper_alias) # N: Revealed type is "__main__.Wrap[Literal[b'foo']]"
284285
285- reveal_type(a_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Literal['foo'] ]"
286- reveal_type(b_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Literal['foo'] ]"
287- reveal_type(c_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Literal[b'foo'] ]"
286+ reveal_type(a_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Any ]"
287+ reveal_type(b_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Any ]"
288+ reveal_type(c_bytes_wrapper_alias) # N: Revealed type is "__main__.Wrap[Any ]"
288289[builtins fixtures/tuple.pyi]
289290[out]
290291
0 commit comments