From b7eaf7264f0ef31c3b06fd0dfe80d4b30ae7bf88 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:02:58 -0400 Subject: [PATCH] Update _main.py --- evmspec/data/_main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evmspec/data/_main.py b/evmspec/data/_main.py index 3cf2771..9dc2099 100644 --- a/evmspec/data/_main.py +++ b/evmspec/data/_main.py @@ -20,6 +20,8 @@ DecodeHook = Callable[[Type[_T], Any], _T] """A type alias for a function that decodes an object into a specific type.""" +__str_new__ = str.__new__ +__hb_new__ = HexBytes.__new__ class Address(str): """ @@ -58,7 +60,7 @@ def __new__(cls, address: str): See Also: - `cchecksum.to_checksum_address`: Function used for checksum conversion. """ - return str.__new__(cls, to_checksum_address(address)) + return __str_new__(cls, to_checksum_address(address)) @classmethod def _decode_hook(cls, typ: Type["Address"], obj: str): @@ -342,7 +344,7 @@ def __new__(cls, v): except KeyError as e: raise ValueError(f"{v} is too long") from e.__cause__ - return HexBytes.__new__(cls, missing_bytes + input_bytes) + return __hb_new__(cls, missing_bytes + input_bytes) def __repr__(self) -> str: return f"{type(self).__name__}({self.hex()})"