Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def format_code(code: str) -> str:
str(formatter_path),
"format",
str(input_file_path),
"--quiet",
"--no-cache",
"--config",
str(config_path),
Expand All @@ -100,7 +99,8 @@ def format_code(code: str) -> str:
if result.returncode != 0:
raise Exception(
f"Error formatting code using formatter '{formatter_path}': "
f"{result.stderr}"
f"returncode={result.returncode}, stdout={result.stdout!r}, "
Comment thread
danceratopz marked this conversation as resolved.
f"stderr={result.stderr!r}"
)

# Return the formatted source code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,37 @@ def signer_minimum_balance(self, *, fork: Fork) -> int:
else:
return gas_price * gas_limit + self.value

def _format_field_value(self, value: Any) -> str:
"""
Format a field value for string representation.

Uses hex encoding for any value that supports it
(Address, Bytes, Hash, HexNumber, etc).
Comment thread
felix314159 marked this conversation as resolved.
Outdated
"""
if value is None:
return "None"
elif hasattr(value, "hex"):
return f'"{value.hex()}"'
else:
return repr(value)

def __repr__(self) -> str:
"""
Return string representation with hex-encoded values for
applicable fields.
"""
field_strs = []
for field_name in self.__class__.model_fields:
value = getattr(self, field_name)
formatted_value = self._format_field_value(value)
field_strs.append(f"{field_name}={formatted_value}")

return f"{self.__class__.__name__}({', '.join(field_strs)})"

def __str__(self) -> str:
"""Return the repr string representation."""
return self.__repr__()


class NetworkWrappedTransaction(CamelModel, RLPSerializable):
"""
Expand Down
Loading