Skip to content

Commit

Permalink
fix regex to remove memory addresses, fix #662 (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils authored Jan 17, 2024
1 parent 26d4082 commit 8c15000
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pdoc/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def default_value_str(self) -> str:
warnings.warn(f"repr({self.fullname}) raised an exception ({e!r})")
return ""

pretty = re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", pretty)
pretty = _remove_memory_addresses(pretty)
return pretty

@cached_property
Expand Down Expand Up @@ -1180,7 +1180,8 @@ def _params(self) -> list[str]:
render_pos_only_separator = False
render_kw_only_separator = True
for param in self.parameters.values():
formatted = re.sub(r" at 0x[0-9a-fA-F]+(?=>$)", "", str(param))
formatted = str(param)
formatted = _remove_memory_addresses(formatted)

kind = param.kind

Expand Down Expand Up @@ -1298,3 +1299,8 @@ def _safe_getdoc(obj: Any) -> str:
return ""
else:
return doc.strip()


def _remove_memory_addresses(x: str) -> str:
"""Remove memory addresses from repr() output"""
return re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", x)

0 comments on commit 8c15000

Please sign in to comment.