From 3d015afb3840a2e51d602a73dffb8aa2d2507171 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:50:53 -0700 Subject: [PATCH] stubtest: reuse is_named_instance (#13504) --- mypy/stubtest.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 378f61471437..1ba11431e0d5 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -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