Changes in repr of multiple classes
This commit is contained in:
parent
f7d20b5fe6
commit
b88bfa53ef
5 changed files with 30 additions and 14 deletions
|
|
@ -121,7 +121,7 @@ class _IFieldStorage:
|
|||
return key in self._storage
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self.__class__.__name__}({repr(self._storage)})"
|
||||
return f"<{self.__class__.__name__} {repr(self._storage)}>"
|
||||
|
||||
|
||||
def _encode_html_entities(value: Union[str, None]) -> Union[str, None]:
|
||||
|
|
|
|||
|
|
@ -125,11 +125,11 @@ class File:
|
|||
|
||||
def __repr__(self) -> str:
|
||||
filename, content_type, size = (
|
||||
repr(self.filename),
|
||||
repr(self.content_type),
|
||||
repr(self.size),
|
||||
self.filename,
|
||||
self.content_type,
|
||||
self.size,
|
||||
)
|
||||
return f"{self.__class__.__name__}({filename=}, {content_type=}, {size=})"
|
||||
return f"<{self.__class__.__name__} {filename=}, {content_type=}, {size=}>"
|
||||
|
||||
|
||||
class Files(_IFieldStorage):
|
||||
|
|
@ -258,7 +258,9 @@ class FormData(_IXSSSafeFieldStorage):
|
|||
|
||||
def __repr__(self) -> str:
|
||||
class_name = self.__class__.__name__
|
||||
return f"{class_name}({repr(self._storage)}, files={repr(self.files._storage)})"
|
||||
return (
|
||||
f"<{class_name} {repr(self._storage)}, files={repr(self.files._storage)}>"
|
||||
)
|
||||
|
||||
|
||||
class Request: # pylint: disable=too-many-instance-attributes
|
||||
|
|
@ -479,6 +481,10 @@ class Request: # pylint: disable=too-many-instance-attributes
|
|||
|
||||
return method, path, query_params, http_version, headers
|
||||
|
||||
def __repr__(self) -> str:
|
||||
path = self.path + (f"?{self.query_params}" if self.query_params else "")
|
||||
return f'<{self.__class__.__name__} "{self.method} {path}">'
|
||||
|
||||
|
||||
def _debug_unsupported_form_content_type(content_type: str) -> None:
|
||||
"""Warns when an unsupported form content type is used."""
|
||||
|
|
|
|||
|
|
@ -136,11 +136,11 @@ class Route:
|
|||
return True, dict(zip(self.parameters_names, url_parameters_values))
|
||||
|
||||
def __repr__(self) -> str:
|
||||
path = repr(self.path)
|
||||
methods = repr(self.methods)
|
||||
handler = repr(self.handler)
|
||||
path = self.path
|
||||
methods = self.methods
|
||||
handler = self.handler
|
||||
|
||||
return f"Route({path=}, {methods=}, {handler=})"
|
||||
return f"<Route {path=}, {methods=}, {handler=}>"
|
||||
|
||||
|
||||
def as_route(
|
||||
|
|
|
|||
|
|
@ -528,6 +528,13 @@ class Server: # pylint: disable=too-many-instance-attributes
|
|||
else:
|
||||
raise ValueError("Server.socket_timeout must be a positive numeric value.")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
host = self.host
|
||||
port = self.port
|
||||
root_path = self.root_path
|
||||
|
||||
return f"<Server {host=}, {port=}, {root_path=}>"
|
||||
|
||||
|
||||
def _debug_warning_exposed_files(root_path: str):
|
||||
"""Warns about exposing all files on the device."""
|
||||
|
|
|
|||
|
|
@ -21,14 +21,17 @@ class Status: # pylint: disable=too-few-public-methods
|
|||
self.code = code
|
||||
self.text = text
|
||||
|
||||
def __repr__(self):
|
||||
return f'Status({self.code}, "{self.text}")'
|
||||
def __eq__(self, other: "Status"):
|
||||
return self.code == other.code and self.text == other.text
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.code} {self.text}"
|
||||
|
||||
def __eq__(self, other: "Status"):
|
||||
return self.code == other.code and self.text == other.text
|
||||
def __repr__(self):
|
||||
code = self.code
|
||||
text = self.text
|
||||
|
||||
return f'<Status {code}, "{text}">'
|
||||
|
||||
|
||||
SWITCHING_PROTOCOLS_101 = Status(101, "Switching Protocols")
|
||||
|
|
|
|||
Loading…
Reference in a new issue