Repository navigation
bpo-34995: Maintain func.__isabstractmethod__ in functools.cached_property #9904
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
Changes from 4 commits
da3ec33
bfdc249
16c0372
db8dcd7
1c91dd2
511c14f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2478,6 +2478,17 @@ def test_access_from_class(self): | |
| def test_doc(self): | ||
| self.assertEqual(CachedCostItem.cost.__doc__, "The cost of the item.") | ||
|
|
||
| def test_isabstractmethod(self): | ||
| class AbstractExpensiveCalculator(abc.ABC): | ||
| @functools.cached_property | ||
| @abc.abstractmethod | ||
| def calculate(self): | ||
| pass | ||
|
|
||
| self.assertTrue(getattr(AbstractExpensiveCalculator.calculate, '__isabstractmethod__', False)) | ||
| with self.assertRaises(TypeError): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to (also) directly check the isabstractmethod attribute?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion, added an assertion for that |
||
| AbstractExpensiveCalculator() | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test on a method which doesn't have the |
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Maintain wrapped method's __isabstractmethod__ in functools.cached_property | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest: |
||
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.
self.assertTrue(AbstractExpensiveCalculator.calculate.isabstractmethod) is enough.