diff --git a/src/requests/status_codes.py b/src/requests/status_codes.py index c7945a2f06..17f85fa9be 100644 --- a/src/requests/status_codes.py +++ b/src/requests/status_codes.py @@ -107,22 +107,17 @@ def _init(): + doc_lines = [] for code, titles in _codes.items(): for title in titles: setattr(codes, title, code) if not title.startswith(("\\", "/")): setattr(codes, title.upper(), code) - - def doc(code): - names = ", ".join(f"``{n}``" for n in _codes[code]) - return "* %d: %s" % (code, names) + doc_lines.append(f"* {code}: {', '.join(f'``{title}``' for title in titles)}") global __doc__ - __doc__ = ( - __doc__ + "\n" + "\n".join(doc(code) for code in sorted(_codes)) - if __doc__ is not None - else None - ) + if __doc__ is not None: + __doc__ += "\n" + "\n".join(doc_lines) _init()