Skip to content

Commit

Permalink
style: improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Jan 10, 2024
1 parent 372a0e5 commit a83d607
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions hooks/gen_docs/gen_docs_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,19 @@
log = logging.getLogger("DocumentationGenerator")


class KpopsComponent(NamedTuple):
"""Stores the names of components fields.
:param attrs: All fields
:param specific_attrs: Fields that are NOT inherited
"""

attrs: list[str]
specific_attrs: list[str]


def collect_parents_mro(component: type[PipelineComponent]) -> list[str]:
"""Return a list of a component's parents.
:param component_name: Component name in kebab-case
:param component: Component name in kebab-case
:return: List ordered from closest to furthest ancestor,
i.e. ``result[0] == component_name``.
"""
comps = []
for c in component.mro():
if patched_issubclass_of_basemodel(c):
bases = []
for base in component.mro():
if patched_issubclass_of_basemodel(base):
with suppress(AttributeError):
comps.append(c.type) # pyright: ignore[reportGeneralTypeIssues]
return comps
bases.append(base.type) # pyright: ignore[reportGeneralTypeIssues]
return bases


KPOPS_COMPONENTS_INHERITANCE_REF = {
Expand All @@ -98,6 +87,17 @@ def collect_parents_mro(component: type[PipelineComponent]) -> list[str]:
}


class KpopsComponent(NamedTuple):
"""Stores the names of components fields.
:param attrs: All fields
:param specific_attrs: Fields that are NOT inherited
"""

attrs: list[str]
specific_attrs: list[str]


def filter_sections(
component_name: str,
sections: list[str],
Expand Down

0 comments on commit a83d607

Please sign in to comment.