Skip to content

Commit 8ba7360

Browse files
committed
Auto-strip snippet assignments
1 parent af10966 commit 8ba7360

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

proplot/internals/docstring.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ def __call__(self, obj):
1919
Add snippets to the string or object using ``%(name)s`` substitution.
2020
This lets snippet keys have invalid variable names.
2121
"""
22-
parts = {key: value.strip() for key, value in self.items()}
2322
if isinstance(obj, str):
24-
obj %= parts # add snippets to a string
23+
obj %= self # add snippets to a string
2524
else:
2625
obj.__doc__ = inspect.getdoc(obj) # also dedents the docstring
2726
if obj.__doc__:
28-
obj.__doc__ %= parts # insert snippets after dedent
27+
obj.__doc__ %= self # insert snippets after dedent
2928
return obj
3029

3130
def __setitem__(self, key, value):
@@ -34,6 +33,7 @@ def __setitem__(self, key, value):
3433
care to import modules in the correct order.
3534
"""
3635
value = self(value)
36+
value = value.strip()
3737
super().__setitem__(key, value)
3838

3939

0 commit comments

Comments
 (0)