8000 Infer correct types with overloads of `Type[Guard | Is]` by sobolevn · Pull Request #17678 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Infer correct types with overloads of Type[Guard | Is] #17678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review
  • Loading branch information
sobolevn committed Jan 17, 2025
commit 50377fab1b8dd0ca5805587d5054474bcfac0101
2 changes: 2 additions & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6037,6 +6037,8 @@ def find_isinstance_check_helper(
# Also note that a care must be taken to unwrap this back at read places
# where we use this to narrow down declared type.
with self.msg.filter_errors(), self.local_type_map():
# `node.callee` can be an `overload`ed function,
# we need to resolve the real `overload` case.
_, real_func = self.expr_checker.check_call(
get_proper_type(self.lookup_type(node.callee)),
node.args,
Expand Down
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6565,7 +6565,7 @@ def all_same_types(types: list[Type]) -> bool:


def all_same_type_narrowers(types: list[CallableType]) -> bool:
if not types:
if len(types) <= 1:
return True

type_guards: list[Type] = []
Expand Down
Loading
0