From a83d607c5b08ab48110a1efbbfe9fa7509f03e26 Mon Sep 17 00:00:00 2001 From: Ivan Yordanov Date: Wed, 10 Jan 2024 16:14:53 +0200 Subject: [PATCH] style: improve naming --- hooks/gen_docs/gen_docs_components.py | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/hooks/gen_docs/gen_docs_components.py b/hooks/gen_docs/gen_docs_components.py index d56709e35..ac08a23ea 100644 --- a/hooks/gen_docs/gen_docs_components.py +++ b/hooks/gen_docs/gen_docs_components.py @@ -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 = { @@ -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],