Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Memory Address Regex #663

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading