-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
docs(ingest): inherit capabilities from superclasses #9174
Changes from all commits
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 |
---|---|---|
|
@@ -93,10 +93,20 @@ def capability( | |
""" | ||
|
||
def wrapper(cls: Type) -> Type: | ||
if not hasattr(cls, "__capabilities"): | ||
if not hasattr(cls, "__capabilities") or any( | ||
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 we just use single underscore instead of double underscore here? I think that's why we have to do this in the first place: https://www.scaler.com/topics/double-underscore-python/ 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. in this case, we actually do want double underscore to signal that it's specific to that class and not subclasses, since the inheritance piece of it we do ourselves using copies to avoid mutating the same underlying object also the double underscores don't actually get mangled here because we're not within a class context |
||
# It's from this class and not a superclass. | ||
cls.__capabilities is getattr(base, "__capabilities", None) | ||
for base in cls.__bases__ | ||
): | ||
cls.__capabilities = {} | ||
cls.get_capabilities = lambda: cls.__capabilities.values() | ||
|
||
# If the superclasses have capability annotations, copy those over. | ||
for base in cls.__bases__: | ||
base_caps = getattr(base, "__capabilities", None) | ||
if base_caps: | ||
cls.__capabilities.update(base_caps) | ||
|
||
cls.__capabilities[capability_name] = CapabilitySetting( | ||
capability=capability_name, description=description, supported=supported | ||
) | ||
|
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 a big deal but the period messes up the link on github