-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Support declaring a Parameterized class as an ABC #1031
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1031 +/- ##
==========================================
+ Coverage 87.26% 87.28% +0.02%
==========================================
Files 9 9
Lines 4939 4947 +8
==========================================
+ Hits 4310 4318 +8
Misses 629 629 ☔ View full report in Codecov by Sentry. |
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.
Looks good to me!
The only thing I want to see before this is merged are some tests making sure the decorators used to declare abstract methods, properties etc. work as expected.
In an ideal world we would run the whole test suite again using ParameterizedABC
to check everything else works but that seems overkill, especially as this base class is opt-in.
@jlstevens I have added some tests and updated the documentation. I also added |
Param has its own way of declaring "abstract" classes by annotating them with
__abstract = True
. Parameterized classes all have anabstract
property inherited from the metaclass that returns whether this attribute (mangled) was set. Theconcrete_descendents
function uses_is_abstract
to build a collection of the non-abstract descendents only. #84 suggests replacing this approach by Abstract Bases Classes. This MR doesn't replace the current mechanism (we'd need to deprecate it first) but instead attempts to add support to ABCs, allowing users to declare a Parameterized ABC.To avoid metaclass conflicts, it introduces the
ParamaterizedABC
class that users must inherit from when they want to declare an ABC.@sdc50 I know your comment on #84 dates a little (5 years :) ). If you're still interested in this feature, let me know what you think about it. On the HoloViz code bases side, I think we'll need to see whether we can effectively replace
__abstract = True
.