[Polish] Simplify __repr__ method in Request class (#5153)

Remove detailed string representation for Request class.
This commit is contained in:
Jiang-Jia-Jun
2025-11-21 17:21:06 +08:00
committed by GitHub
parent 6471dade4a
commit d2298dcb0c

View File

@@ -310,19 +310,7 @@ class Request:
def __repr__(self) -> str:
"""Safe string representation that ignores private and None fields."""
try:
if not envs.FD_DEBUG:
return f"Request(request_id={self.request_id})"
else:
attrs_snapshot = dict(vars(self))
non_none_fields = [
f"{attr}={value!r}"
for attr, value in attrs_snapshot.items()
if value is not None and not attr.startswith("_")
]
return f"Request({', '.join(non_none_fields)})"
except Exception as e:
return f"<{self.__class__.__name__} repr failed: {e}>"
return ""
@dataclass(slots=True)