-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix crash on properties & inherited methods in implicit-booleaness
#5652
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
Conversation
@Pierre-Sassoulas You seem to have written the test that is currently failing. Could it be that this is a non-sensical test? Seeing as that the functional tests all pass it seems like we don't ever pass I'll wait for the primer to pass, but this might be a non-real-world test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably messed the test up by giving class def instead of instances but the code also work for instances (?)
return [instance.name] + [x.name for x in instance.ancestors()] | ||
except TypeError: | ||
return [instance.name] | ||
def base_classes_and_return_names( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should have two functions, one for unbound method (base_classes_of_returned_instance
) and one for instances (base_classes_of_instance
). This new function is handling two cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure.. How would we then call the function that calls base_classes_of_returned_instance
and base_classes_of_instance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need one ? It seems the code before was not handling returned instances ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what the crash is about. We don't only get Instances
here but also UnboundMethod
whenever one of the compared values is a property
.
This is basically three changes in one: fix method typing to actually reflect that is handling Instances
+ update method to also handle UnboundMethod
+ update method to also handle Uninsurable
(and everything else that is not Instance
or UnboundMethod
. Perhaps I should have split this, but felt that this made more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand now. Maybe the original name, "base class of node" is generic enough (and future proof if we encounter exotic codebase that will have other nodes) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to base_names_of_base_node
, let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was outdated when you did your review. Are you also okay with the new new name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'll merge 🎉
Yes, since instances are derived from classes and have an |
Pull Request Test Coverage Report for Build 1694033305
💛 - Coveralls |
doc/whatsnew/<current release.rst>
.Type of Changes
Description
Closes #5646 and supersedes #5647.
The typing on this function was incorrect and never actually received classes. Instead it received
bases.Instance
which was also deductible from the parameter name. I've completely rewritten the function as I felt this was the best way to go.