Skip to content

Commit 054dd1f

Browse files
committed
Fix CI
1 parent ef9a659 commit 054dd1f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mypy/types_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def is_bad_type_type_item(item: Type) -> bool:
8282
Such types are explicitly prohibited by PEP 484. Also, they cause problems
8383
with recursive types like T = Type[T], because internal representation of
8484
TypeType item is normalized (i.e. always a proper type).
85+
86+
Also forbids `Type[Literal[...]]`, because typing spec does not allow it.
8587
"""
8688
item = get_proper_type(item)
8789
if isinstance(item, (TypeType, LiteralType)):

test-data/unit/check-recursive-types.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,10 @@ def local() -> None:
409409
x: L
410410
reveal_type(x) # N: Revealed type is "builtins.list[Union[builtins.int, Any]]"
411411

412-
S = Type[S] # E: Type[...] can't contain another Type[...]
413-
U = Type[Union[int, U]] # E: Type[...] can't contain another Type[...]
412+
S = Type[S] # E: Type[...] can't contain "type[<placeholder __main__.S>]" \
413+
# E: Type[...] can't contain "type[Any]"
414+
U = Type[Union[int, U]] # E: Type[...] can't contain "Union[builtins.int, Union[type[builtins.int], type[<placeholder __main__.U>]]]" \
415+
# E: Type[...] can't contain "Union[builtins.int, type[Any]]"
414416
x: U
415417
reveal_type(x) # N: Revealed type is "Type[Any]"
416418

0 commit comments

Comments
 (0)