-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add functools.wraps
support for is_overridden
#8296
Conversation
@awaelchli Do we need this in the bugfix branch? |
Codecov Report
@@ Coverage Diff @@
## master #8296 +/- ##
======================================
- Coverage 92% 92% -0%
======================================
Files 213 213
Lines 13804 13806 +2
======================================
- Hits 12749 12738 -11
- Misses 1055 1068 +13 |
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.
oh this is very nice! I would have never figured this out <3
Don't think so, because calling the methods when they are not implemented will do nothing. So it's not noticable and apart from the has_x_called there are no side effects afaik. |
return 2 | ||
|
||
# `functools.wraps()` support | ||
assert not is_overridden("foo", WrappedModel(), parent=TestModel) |
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 this shall mark as overwritten as a wrapped can significantly change its functionality...
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.
The current implementation assumes that the wrapper will be the same both for the instance and the parent
Not sure whether we could check if the wrappers are different
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.
can you detect what wrapper was used and then compare the wrapper itself?
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.
Can detect that a wrapper was used (current PR changes) but no idea about comparing the wrappers
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.
Could we check if the wrapper is from Lightning
or users
?
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.
Might be worth for another PR. I believe this is a pretty rare use-case.
What does this PR do?
Fixes #8273
Some very minor doc fixes are included
Before submitting
PR review