Skip to content

Fix incorrect type inference for inherited from Any class #8019

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 5 commits into from
Dec 13, 2019
Merged

Fix incorrect type inference for inherited from Any class #8019

merged 5 commits into from
Dec 13, 2019

Conversation

TH3CHARLie
Copy link
Collaborator

@TH3CHARLie TH3CHARLie commented Nov 27, 2019

resolves #8001

@TH3CHARLie TH3CHARLie changed the title Fix incorrect type analysis for inherited from Any class Fix incorrect type inference for inherited from Any class Dec 2, 2019
Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I'll merge it tomorrow unless @ilevkivskyi or @Michael0x2a have more feedback

# if so, we also return Any
if ((isinstance(left_type, Instance) and left_type.type.fallback_to_any) or
(isinstance(right_type, Instance) and right_type.type.fallback_to_any)):
any_type = AnyType(TypeOfAny.special_form)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if special_form is the right thing here but I'm not totally sure what else to do. from_another_any is correct but digging out the other any is almost certainly not worth bothering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also not sure about whether special_form is the right thing to go, but clearly directly using from_another_any with either left_type or right_type here is incorrect. To proper use from_another_any, we need a better way to transform the Instance to an Any

@msullivan
Copy link
Collaborator

Oh, I guess please fix the merge conflict

@TH3CHARLie
Copy link
Collaborator Author

Oh, I guess please fix the merge conflict

fixed

@msullivan msullivan merged commit 8a08e78 into python:master Dec 13, 2019
@TH3CHARLie TH3CHARLie deleted the fix-false-positive-multiply-float-with-Any branch December 14, 2019 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Float multiplication of numpy.ndarray in lambda is incorrectly analysed
4 participants