Skip to content

Commit

Permalink
is_named_instance should be a TypeGuard (#13543)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Aug 28, 2022
1 parent 6250063 commit 1a3d601
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4246,7 +4246,7 @@ def get_types_from_except_handler(self, typ: Type, n: Expression) -> list[Type]:
for item in typ.relevant_items()
for union_typ in self.get_types_from_except_handler(item, n)
]
elif isinstance(typ, Instance) and is_named_instance(typ, "builtins.tuple"):
elif is_named_instance(typ, "builtins.tuple"):
# variadic tuple
return [typ.args[0]]
else:
Expand Down
4 changes: 2 additions & 2 deletions mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Union,
cast,
)
from typing_extensions import Final, TypeAlias as _TypeAlias, overload
from typing_extensions import Final, TypeAlias as _TypeAlias, TypeGuard, overload

import mypy.nodes
from mypy.bogus_type import Bogus
Expand Down Expand Up @@ -3172,7 +3172,7 @@ def strip_type(typ: Type) -> Type:
return orig_typ


def is_named_instance(t: Type, fullnames: str | tuple[str, ...]) -> bool:
def is_named_instance(t: Type, fullnames: str | tuple[str, ...]) -> TypeGuard[Instance]:
if not isinstance(fullnames, tuple):
fullnames = (fullnames,)

Expand Down

0 comments on commit 1a3d601

Please sign in to comment.