Skip to content

Commit b4f6fde

Browse files
feat(mathy_pydoc): fix formatting of str defaults
1 parent 6ba8bf6 commit b4f6fde

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

libraries/mathy_pydoc/mathy_pydoc/loader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ def get_callable_placeholder(
189189
if p.annotation is not inspect._empty: # type: ignore
190190
annotation = inspect.formatannotation(p.annotation)
191191
if p.default is not inspect._empty: # type: ignore
192-
default_value = str(p.default)
193-
192+
if isinstance(p.default, str):
193+
default_value = repr(p.default)
194+
else:
195+
default_value = str(p.default)
194196
if annotation is not None:
195197
annotation = cleanup_type(annotation)
196198
params.append(CallableArg(p.name, annotation, default_value))

libraries/mathy_pydoc/testmodule/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def a_function_with_types(
66
nested_optional: Optional[Tuple[Optional[str], Optional[int]]],
77
inputs: List[Dict[str, Any]],
88
auxiliary: Tuple[Optional[str]],
9+
another: str = "\t",
910
final: int = 3,
1011
) -> List[Optional[str]]:
1112
"""Sweet typed function"""

0 commit comments

Comments
 (0)