diff --git a/hexbytes/main.py b/hexbytes/main.py index ca24783..e9c9465 100644 --- a/hexbytes/main.py +++ b/hexbytes/main.py @@ -4,7 +4,6 @@ Tuple, Type, Union, - cast, overload, ) @@ -31,9 +30,9 @@ class HexBytes(bytes): 3. ``to_0x_hex`` returns a 0x-prefixed hex string """ - def __new__(cls: Type[bytes], val: BytesLike) -> "HexBytes": + def __new__(cls, val: BytesLike) -> "HexBytes": bytesval = to_bytes(val) - return cast(HexBytes, super().__new__(cls, bytesval)) # type: ignore # https://github.com/python/typeshed/issues/2630 # noqa: E501 + return super().__new__(cls, bytesval) @overload def __getitem__(self, key: "SupportsIndex") -> int: # noqa: F811 diff --git a/newsfragments/55.performance.rst b/newsfragments/55.performance.rst new file mode 100644 index 0000000..ce90e26 --- /dev/null +++ b/newsfragments/55.performance.rst @@ -0,0 +1 @@ +remove redundant cast in __new__