8000 Correctly handle TypeOfAny.from_another_any by ilevkivskyi · Pull Request #15497 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Correctly handle TypeOfAny.from_another_any #15497

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

Closed
wants to merge 2 commits into from
Closed
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
Fix self-check
  • Loading branch information
ilevkivskyi committed Jun 22, 2023
commit bee47c627abe85383e81e068e5d409d04878cef8
10 changes: 6 additions & 4 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5365,10 +5365,12 @@ def __init__(self, ignore_in_type_obj: bool) -> None:
def visit_any(self, t: AnyType) -> bool:
# Special forms are not real Any types (note that we don't need to recurse
# since AnyType constructor finds actual source).
return t.type_of_any != TypeOfAny.special_form and not (
t.type_of_any == TypeOfAny.from_another_any
and t.source_any.type_of_any == TypeOfAny.special_form
)
if t.type_of_any == TypeOfAny.special_form:
return False
if t.type_of_any == TypeOfAny.from_another_any:
assert t.source_any is not None
return t.source_any.type_of_any != TypeOfAny.special_form
return True

def visit_callable_type(self, t: CallableType) -> bool:
if self.ignore_in_type_obj and t.is_type_obj():
Expand Down
0