-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-77465: Increase test coverage for numbers
#111738
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
numbers
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.
There is too many code for implementing methods that are not used, just to allow instantiation of the subclass of an abstract class. I suggest to generate them.
import abc
def not_implemented(*args, **kwargs):
raise NotImplementedError
def concretize(cls):
for name in dir(cls):
try:
value = getattr(cls, name)
if value.__isabstractmethod__:
setattr(cls, name, not_implemented)
except AttributeError:
pass
abc.update_abstractmethods(cls)
return cls
You can just apply this decorator to subclasses and remove all dummy methods.
Co-authored-by: Serhiy Storchaka <[email protected]>
Thanks for the review, applied! |
Co-authored-by: Serhiy Storchaka <[email protected]>
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.
LGTM.
Thanks @aisk for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
…GH-111738) (cherry picked from commit e721adf) Co-authored-by: AN Long <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
…GH-111738) (cherry picked from commit e721adf) Co-authored-by: AN Long <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
GH-114556 is a backport of this pull request to the 3.12 branch. |
GH-114557 is a backport of this pull request to the 3.11 branch. |
…1738) (GH-114557) (cherry picked from commit e721adf) Co-authored-by: AN Long <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
…1738) (GH-114556) (cherry picked from commit e721adf) Co-authored-by: AN Long <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
…GH-111738) Co-authored-by: Serhiy Storchaka <[email protected]>
…GH-111738) Co-authored-by: Serhiy Storchaka <[email protected]>
Most classes in
numbers
are ABCs, but they have default implementations for some methods, for example,Complex.__bool__
. Although the impementations are simple, but they should have been tested.