Skip to content

Commit

Permalink
fix doc inheritance for Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSellner committed Oct 2, 2024
1 parent 97d3e9e commit 477e180
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/blosc2/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def wrapper(child_func):
indent_parent = None
for line in parent_func.__doc__.splitlines():
if parameter in line:
match = re.search(rf"(\s+){parameter}", line)
match = re.search(rf"(\s*){parameter}", line)
assert (
match is not None
), f"Parameter {parameter} not found in the docstring of {parent_func.__name__}"
Expand All @@ -35,7 +35,11 @@ def wrapper(child_func):
match is not None
), f"Parameter {parameter} not found in the docstring of {child_func.__name__}"
indent_child = match.group(1)
matching_lines = [ml.replace(indent_parent, indent_child, 1) for ml in matching_lines]

# First line contains the parameter name itself which should not be indented
matching_lines = [matching_lines[0].lstrip()] + [
ml.replace(indent_parent, indent_child, 1) for ml in matching_lines[1:]
]

child_func.__doc__ = child_func.__doc__.replace(parameter, "\n".join(matching_lines))

Expand Down

0 comments on commit 477e180

Please sign in to comment.