Skip to content

Commit

Permalink
Misc refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine DECHAUME committed Oct 19, 2023
1 parent 148ad65 commit 6e743e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BaseDocstringInheritor:
MISSING_ARG_DESCRIPTION: ClassVar[str] = "The description is missing."
"""The fall back description for a method argument without a description."""

INHERIT_SECTION_TAG: ClassVar[str] = "__inherit_section_doc__"
INHERIT_SECTION_PLACEHOLDER: ClassVar[str] = "__inherit_doc__"
"""Placeholder used to indicate that a section docstring shall be inherited."""

_MISSING_ARG_TEXT: ClassVar[str]
Expand Down Expand Up @@ -92,7 +92,7 @@ def _filters_inherited_sections(
for key, item in tuple(sections.items()):
if isinstance(item, dict):
cls._filters_inherited_sections(cast(SectionsType, item))
elif item.strip().startswith(cls.INHERIT_SECTION_TAG):
elif item.strip().startswith(cls.INHERIT_SECTION_PLACEHOLDER):
del sections[key]

@classmethod
Expand Down
4 changes: 1 addition & 3 deletions src/docstring_inheritance/docstring_inheritors/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def _parse_one_section(


class NumpyDocstringInheritor(BaseDocstringInheritor):
_MISSING_ARG_TEXT: ClassVar[
str
] = f"\n {BaseDocstringInheritor.MISSING_ARG_DESCRIPTION}"
_MISSING_ARG_TEXT = f"\n {BaseDocstringInheritor.MISSING_ARG_DESCRIPTION}"
_DOCSTRING_PARSER = DocstringParser
_DOCSTRING_RENDERER = DocstringRenderer
8 changes: 4 additions & 4 deletions tests/test_base_inheritor.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ def test_inherit_section_items_with_args(func, section_items, expected):
({}, {}),
({"": ""}, {"": ""}),
({"": {"": ""}}, {"": {"": ""}}),
({"": "__inherit_section_doc__"}, {}),
({"": "__inherit_section_doc__", "a": ""}, {"a": ""}),
({"": {"": "__inherit_section_doc__"}}, {"": {}}),
({"": {"": "__inherit_section_doc__", "a": ""}}, {"": {"a": ""}}),
({"": "__inherit_doc__"}, {}),
({"": "__inherit_doc__", "a": ""}, {"a": ""}),
({"": {"": "__inherit_doc__"}}, {"": {}}),
({"": {"": "__inherit_doc__", "a": ""}}, {"": {"a": ""}}),
),
)
def test_filter_inherited_sections(sections, expected):
Expand Down

0 comments on commit 6e743e9

Please sign in to comment.