Skip to content

Commit

Permalink
Fix docstring indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
greschd committed Oct 3, 2024
1 parent 85f3071 commit b1927c0
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from collections.abc import Callable
from functools import reduce
import sys
from typing import TYPE_CHECKING, Any, TypeVar

from google.protobuf.message import Message
Expand Down Expand Up @@ -93,8 +94,20 @@ def mark_grpc_properties(cls: T) -> T:
cls._GRPC_PROPERTIES = tuple(props_unique)
if cls._SUPPORTED_SINCE is not None:
if isinstance(cls.__doc__, str):

Check warning on line 96 in src/ansys/acp/core/_tree_objects/_grpc_helpers/property_helper.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/acp/core/_tree_objects/_grpc_helpers/property_helper.py#L96

Added line #L96 was not covered by tests
# When adding to the docstring, we need to match the existing
# indentation of the docstring (except the first line).
# See PEP 257 'Handling Docstring Indentation'.
# Alternatively, we could strip the common indentation from the
# docstring.
indent = sys.maxsize
for line in cls.__doc__.splitlines()[1:]:
stripped = line.lstrip()
if stripped: # ignore empty lines
indent = min(indent, len(line) - len(stripped))
if indent == sys.maxsize:
indent = 0
cls.__doc__ += (

Check warning on line 109 in src/ansys/acp/core/_tree_objects/_grpc_helpers/property_helper.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/acp/core/_tree_objects/_grpc_helpers/property_helper.py#L102-L109

Added lines #L102 - L109 were not covered by tests
f"\n\nSupported since ACP gRPC server version {cls._SUPPORTED_SINCE}.\n\n"
f"\n\n{indent * ' '}*Added in ACP server version {cls._SUPPORTED_SINCE}.*\n"
)
return cls

Expand Down

0 comments on commit b1927c0

Please sign in to comment.