Skip to content

Commit

Permalink
stubtest: reuse is_named_instance (#13504)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja authored Aug 25, 2022
1 parent a56fcac commit 3d015af
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,16 +1270,13 @@ def is_subtype_helper(left: mypy.types.Type, right: mypy.types.Type) -> bool:
isinstance(left, mypy.types.LiteralType)
and isinstance(left.value, int)
and left.value in (0, 1)
and isinstance(right, mypy.types.Instance)
and right.type.fullname == "builtins.bool"
and mypy.types.is_named_instance(right, "builtins.bool")
):
# Pretend Literal[0, 1] is a subtype of bool to avoid unhelpful errors.
return True

if (
isinstance(right, mypy.types.TypedDictType)
and isinstance(left, mypy.types.Instance)
and left.type.fullname == "builtins.dict"
if isinstance(right, mypy.types.TypedDictType) and mypy.types.is_named_instance(
left, "builtins.dict"
):
# Special case checks against TypedDicts
return True
Expand Down

0 comments on commit 3d015af

Please sign in to comment.