faster-hexbytes 1.3.5__tar.gz → 1.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {faster_hexbytes-1.3.5/faster_hexbytes.egg-info → faster_hexbytes-1.3.7}/PKG-INFO +5 -6
  2. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes/_utils.py +6 -3
  3. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes/main.py +12 -1
  4. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7/faster_hexbytes.egg-info}/PKG-INFO +5 -6
  5. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes.egg-info/requires.txt +3 -3
  6. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/pyproject.toml +5 -2
  7. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/scripts/benchmark/generate_benchmark_markdown.py +1 -1
  8. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/scripts/benchmark/parse_benchmark_output.py +7 -6
  9. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/setup.py +6 -7
  10. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/tests/core/test_hexbytes.py +60 -35
  11. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/tests/core/test_import_and_version.py +2 -2
  12. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/LICENSE +0 -0
  13. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/MANIFEST.in +0 -0
  14. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/README.md +0 -0
  15. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes/__init__.py +0 -0
  16. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes/py.typed +0 -0
  17. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes.egg-info/SOURCES.txt +0 -0
  18. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes.egg-info/dependency_links.txt +0 -0
  19. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes.egg-info/not-zip-safe +0 -0
  20. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/faster_hexbytes.egg-info/top_level.txt +0 -0
  21. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/scripts/benchmark/compare_benchmark_results.py +0 -0
  22. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/scripts/release/test_package.py +0 -0
  23. {faster_hexbytes-1.3.5 → faster_hexbytes-1.3.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster_hexbytes
3
- Version: 1.3.5
3
+ Version: 1.3.7
4
4
  Summary: A faster fork of hexbytes: Python `bytes` subclass that decodes hex, with a readable console output. Implemented in C.
5
5
  Home-page: https://github.com/BobTheBuidler/faster-hexbytes
6
6
  Author: The Ethereum Foundation
@@ -20,13 +20,12 @@ Classifier: Intended Audience :: Developers
20
20
  Classifier: License :: OSI Approved :: MIT License
21
21
  Classifier: Natural Language :: English
22
22
  Classifier: Programming Language :: Python :: 3
23
- Classifier: Programming Language :: Python :: 3.9
24
23
  Classifier: Programming Language :: Python :: 3.10
25
24
  Classifier: Programming Language :: Python :: 3.11
26
25
  Classifier: Programming Language :: Python :: 3.12
27
26
  Classifier: Programming Language :: Python :: 3.13
28
27
  Classifier: Programming Language :: Python :: 3.14
29
- Requires-Python: >=3.9, <4
28
+ Requires-Python: >=3.10, <4
30
29
  Description-Content-Type: text/markdown
31
30
  License-File: LICENSE
32
31
  Requires-Dist: hexbytes==1.3.1
@@ -36,7 +35,7 @@ Provides-Extra: dev
36
35
  Requires-Dist: build>=0.9.0; extra == "dev"
37
36
  Requires-Dist: bump_my_version>=0.19.0; extra == "dev"
38
37
  Requires-Dist: ipython; extra == "dev"
39
- Requires-Dist: mypy==1.19.1; extra == "dev"
38
+ Requires-Dist: mypy==1.20.0; extra == "dev"
40
39
  Requires-Dist: pre-commit>=3.4.0; extra == "dev"
41
40
  Requires-Dist: tox>=4.0.0; extra == "dev"
42
41
  Requires-Dist: twine; extra == "dev"
@@ -61,10 +60,10 @@ Requires-Dist: pytest>=7.0.0; extra == "test"
61
60
  Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
62
61
  Provides-Extra: benchmark
63
62
  Requires-Dist: pytest-benchmark; extra == "benchmark"
64
- Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "benchmark"
63
+ Requires-Dist: pytest-codspeed<4.4,>=4.3; extra == "benchmark"
65
64
  Requires-Dist: eth-typing; extra == "benchmark"
66
65
  Provides-Extra: codspeed
67
- Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "codspeed"
66
+ Requires-Dist: pytest-codspeed<4.4,>=4.3; extra == "codspeed"
68
67
  Requires-Dist: eth-typing; extra == "codspeed"
69
68
  Dynamic: author
70
69
  Dynamic: author-email
@@ -29,7 +29,7 @@ def to_bytes(val: Union[bytes, str, bytearray, bool, int, memoryview]) -> bytes:
29
29
  if val < 0:
30
30
  raise ValueError(f"Cannot convert negative integer {val} to bytes")
31
31
  else:
32
- return to_bytes(hex(val))
32
+ return val.to_bytes(max(1, (val.bit_length() + 7) // 8), "big")
33
33
  elif isinstance(val, memoryview):
34
34
  return bytes(val)
35
35
  else:
@@ -37,13 +37,16 @@ def to_bytes(val: Union[bytes, str, bytearray, bool, int, memoryview]) -> bytes:
37
37
 
38
38
 
39
39
  def hexstr_to_bytes(hexstr: str) -> bytes:
40
- if hexstr.startswith(("0x", "0X")):
40
+ if hexstr.startswith("0x") or hexstr.startswith("0X"):
41
41
  non_prefixed_hex = hexstr[2:]
42
42
  else:
43
43
  non_prefixed_hex = hexstr
44
44
 
45
+ if not non_prefixed_hex:
46
+ return b""
47
+
45
48
  # if the hex string is odd-length, then left-pad it to an even length
46
- if len(hexstr) % 2:
49
+ if len(non_prefixed_hex) & 1:
47
50
  padded_hex = "0" + non_prefixed_hex
48
51
  else:
49
52
  padded_hex = non_prefixed_hex
@@ -3,6 +3,7 @@ from typing import (
3
3
  Callable,
4
4
  Final,
5
5
  Union,
6
+ cast,
6
7
  overload,
7
8
  )
8
9
 
@@ -45,6 +46,12 @@ class HexBytes(hexbytes.HexBytes):
45
46
  """
46
47
 
47
48
  def __new__(cls, val: BytesLike) -> Self:
49
+ if type(val) is cls:
50
+ # These are immutable, just return it
51
+ return val
52
+ elif isinstance(val, bytes):
53
+ # These don't require `to_bytes`
54
+ return _bytes_new(cls, val)
48
55
  bytesval = to_bytes(val)
49
56
  return _bytes_new(cls, bytesval)
50
57
 
@@ -65,7 +72,11 @@ class HexBytes(hexbytes.HexBytes):
65
72
  cls = type(self)
66
73
  if cls is HexBytes:
67
74
  # fast-path case with faster C code for non-subclass
68
- return HexBytes(result) # type: ignore [return-value]
75
+ if isinstance(key, slice):
76
+ # fast-path case to skip __init__
77
+ return cast(Self, _bytes_new(HexBytes, result))
78
+ else:
79
+ return cast(Self, HexBytes(result))
69
80
  return cls(result)
70
81
 
71
82
  def __repr__(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster_hexbytes
3
- Version: 1.3.5
3
+ Version: 1.3.7
4
4
  Summary: A faster fork of hexbytes: Python `bytes` subclass that decodes hex, with a readable console output. Implemented in C.
5
5
  Home-page: https://github.com/BobTheBuidler/faster-hexbytes
6
6
  Author: The Ethereum Foundation
@@ -20,13 +20,12 @@ Classifier: Intended Audience :: Developers
20
20
  Classifier: License :: OSI Approved :: MIT License
21
21
  Classifier: Natural Language :: English
22
22
  Classifier: Programming Language :: Python :: 3
23
- Classifier: Programming Language :: Python :: 3.9
24
23
  Classifier: Programming Language :: Python :: 3.10
25
24
  Classifier: Programming Language :: Python :: 3.11
26
25
  Classifier: Programming Language :: Python :: 3.12
27
26
  Classifier: Programming Language :: Python :: 3.13
28
27
  Classifier: Programming Language :: Python :: 3.14
29
- Requires-Python: >=3.9, <4
28
+ Requires-Python: >=3.10, <4
30
29
  Description-Content-Type: text/markdown
31
30
  License-File: LICENSE
32
31
  Requires-Dist: hexbytes==1.3.1
@@ -36,7 +35,7 @@ Provides-Extra: dev
36
35
  Requires-Dist: build>=0.9.0; extra == "dev"
37
36
  Requires-Dist: bump_my_version>=0.19.0; extra == "dev"
38
37
  Requires-Dist: ipython; extra == "dev"
39
- Requires-Dist: mypy==1.19.1; extra == "dev"
38
+ Requires-Dist: mypy==1.20.0; extra == "dev"
40
39
  Requires-Dist: pre-commit>=3.4.0; extra == "dev"
41
40
  Requires-Dist: tox>=4.0.0; extra == "dev"
42
41
  Requires-Dist: twine; extra == "dev"
@@ -61,10 +60,10 @@ Requires-Dist: pytest>=7.0.0; extra == "test"
61
60
  Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
62
61
  Provides-Extra: benchmark
63
62
  Requires-Dist: pytest-benchmark; extra == "benchmark"
64
- Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "benchmark"
63
+ Requires-Dist: pytest-codspeed<4.4,>=4.3; extra == "benchmark"
65
64
  Requires-Dist: eth-typing; extra == "benchmark"
66
65
  Provides-Extra: codspeed
67
- Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "codspeed"
66
+ Requires-Dist: pytest-codspeed<4.4,>=4.3; extra == "codspeed"
68
67
  Requires-Dist: eth-typing; extra == "codspeed"
69
68
  Dynamic: author
70
69
  Dynamic: author-email
@@ -4,18 +4,18 @@ typing-extensions<5,>=4.0.0
4
4
 
5
5
  [benchmark]
6
6
  pytest-benchmark
7
- pytest-codspeed<4.3,>=4.2
7
+ pytest-codspeed<4.4,>=4.3
8
8
  eth-typing
9
9
 
10
10
  [codspeed]
11
- pytest-codspeed<4.3,>=4.2
11
+ pytest-codspeed<4.4,>=4.3
12
12
  eth-typing
13
13
 
14
14
  [dev]
15
15
  build>=0.9.0
16
16
  bump_my_version>=0.19.0
17
17
  ipython
18
- mypy==1.19.1
18
+ mypy==1.20.0
19
19
  pre-commit>=3.4.0
20
20
  tox>=4.0.0
21
21
  twine
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools", "wheel", "mypy[mypyc]==1.19.1", "hexbytes==1.3.1"]
2
+ requires = ["setuptools", "wheel", "mypy[mypyc]==1.20.0", "hexbytes==1.3.1"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.autoflake]
@@ -20,6 +20,9 @@ profile = "black"
20
20
  use_parentheses = true
21
21
 
22
22
  [tool.mypy]
23
+ packages = ["faster_hexbytes"]
24
+ pretty = true
25
+ no_implicit_reexport = true
23
26
  check_untyped_defs = true
24
27
  disallow_any_generics = true
25
28
  disallow_incomplete_defs = true
@@ -129,7 +132,7 @@ name = "Removals"
129
132
  showcontent = true
130
133
 
131
134
  [tool.bumpversion]
132
- current_version = "1.3.5"
135
+ current_version = "1.3.7"
133
136
  parse = """
134
137
  (?P<major>\\d+)
135
138
  \\.(?P<minor>\\d+)
@@ -2,7 +2,7 @@ import os
2
2
  import json
3
3
 
4
4
 
5
- def main():
5
+ def main() -> None:
6
6
  diff_path = "pytest_benchmark_diff.json"
7
7
  results_dir = os.path.join("benchmarks", "results")
8
8
  os.makedirs(results_dir, exist_ok=True)
@@ -12,11 +12,10 @@ Usage:
12
12
  import json
13
13
  import sys
14
14
  import re
15
- from collections import defaultdict
16
- from typing import Dict, Any
15
+ from typing import Any
17
16
 
18
17
 
19
- def get_submodule(bench: dict) -> str:
18
+ def get_submodule(bench: dict[str, Any]) -> str:
20
19
  # Extract Python submodule from fullname, e.g., "benchmarks/test_abi_benchmarks.py::test_abi_to_signature"
21
20
  fullname = bench.get("fullname", "")
22
21
  # Try to extract the submodule from the test file path
@@ -37,19 +36,21 @@ def get_group_name(test_name: str) -> str:
37
36
  return test_name
38
37
 
39
38
 
40
- def parse_pytest_benchmark_json(data: dict) -> Dict[str, Dict[str, Dict[str, Any]]]:
39
+ def parse_pytest_benchmark_json(
40
+ data: dict[str, Any],
41
+ ) -> dict[str, dict[str, dict[str, Any]]]:
41
42
  """
42
43
  Parses pytest-benchmark's benchmark.json and extracts per-function timings,
43
44
  grouped by submodule and group name.
44
45
  Returns a dict: {submodule: {group: {function_name: {...}}}}
45
46
  """
46
- results = defaultdict(lambda: defaultdict(dict))
47
+ results: dict[str, dict[str, dict[str, Any]]] = {}
47
48
  for bench in data.get("benchmarks", []):
48
49
  name = bench["name"]
49
50
  submodule = get_submodule(bench)
50
51
  group = get_group_name(name)
51
52
  stats = bench["stats"]
52
- results[submodule][group][name] = {
53
+ results.setdefault(submodule, {}).setdefault(group, {})[name] = {
53
54
  "mean": stats.get("mean"),
54
55
  "stddev": stats.get("stddev", None),
55
56
  "iqr": stats.get("iqr", None),
@@ -7,7 +7,7 @@ from setuptools import (
7
7
  from mypyc.build import mypycify
8
8
 
9
9
 
10
- version = "1.3.5"
10
+ version = "1.3.7"
11
11
  hexbytes_version = "1.3.1"
12
12
 
13
13
  extras_require = {
@@ -15,7 +15,7 @@ extras_require = {
15
15
  "build>=0.9.0",
16
16
  "bump_my_version>=0.19.0",
17
17
  "ipython",
18
- "mypy==1.19.1",
18
+ "mypy==1.20.0",
19
19
  "pre-commit>=3.4.0",
20
20
  "tox>=4.0.0",
21
21
  "twine",
@@ -35,11 +35,11 @@ extras_require = {
35
35
  ],
36
36
  "benchmark": [
37
37
  "pytest-benchmark",
38
- "pytest-codspeed>=4.2,<4.3",
38
+ "pytest-codspeed>=4.3,<4.4",
39
39
  "eth-typing",
40
40
  ],
41
41
  "codspeed": [
42
- "pytest-codspeed>=4.2,<4.3",
42
+ "pytest-codspeed>=4.3,<4.4",
43
43
  "eth-typing",
44
44
  ],
45
45
  }
@@ -63,7 +63,7 @@ if skip_mypyc:
63
63
  ext_modules = []
64
64
  else:
65
65
  ext_modules = mypycify(
66
- ["faster_hexbytes/", "--strict", "--pretty"],
66
+ ["faster_hexbytes/"],
67
67
  group_name="faster_hexbytes",
68
68
  strict_dunder_typing=True,
69
69
  )
@@ -95,7 +95,7 @@ setup(
95
95
  "mypy_extensions>=0.4.2,<2",
96
96
  "typing-extensions>=4.0.0,<5",
97
97
  ],
98
- python_requires=">=3.9, <4",
98
+ python_requires=">=3.10, <4",
99
99
  extras_require=extras_require,
100
100
  py_modules=["faster_hexbytes"],
101
101
  license="MIT",
@@ -119,7 +119,6 @@ setup(
119
119
  "License :: OSI Approved :: MIT License",
120
120
  "Natural Language :: English",
121
121
  "Programming Language :: Python :: 3",
122
- "Programming Language :: Python :: 3.9",
123
122
  "Programming Language :: Python :: 3.10",
124
123
  "Programming Language :: Python :: 3.11",
125
124
  "Programming Language :: Python :: 3.12",
@@ -1,24 +1,42 @@
1
- import pytest
2
1
  import pickle
2
+ from typing import (
3
+ Any,
4
+ Callable,
5
+ Final,
6
+ TypeVar,
7
+ cast,
8
+ )
9
+
10
+ import hypothesis
11
+ import pytest
3
12
 
4
13
  from eth_utils import (
5
14
  decode_hex,
6
15
  remove_0x_prefix,
7
- to_bytes as standard_to_bytes,
16
+ to_bytes,
8
17
  )
9
- from hypothesis import (
10
- given,
11
- strategies as st,
18
+ from typing_extensions import (
19
+ ParamSpec,
12
20
  )
13
21
 
14
22
  from faster_hexbytes import (
15
23
  HexBytes,
16
24
  )
17
25
 
18
- hexstr_strategy = st.from_regex(r"\A(0[xX])?[0-9a-fA-F]*\Z")
26
+ P = ParamSpec("P")
27
+ R = TypeVar("R")
28
+
29
+ hexstr_strategy: Final = hypothesis.strategies.from_regex(r"\A(0[xX])?[0-9a-fA-F]*\Z")
19
30
 
20
31
 
21
- def assert_equal(hexbytes, bytes_expected):
32
+ def given(*args: Any, **kwargs: Any) -> Callable[[Callable[P, R]], Callable[P, R]]:
33
+ return cast(
34
+ Callable[[Callable[P, R]], Callable[P, R]],
35
+ hypothesis.given(*args, **kwargs),
36
+ )
37
+
38
+
39
+ def assert_equal(hexbytes: HexBytes, bytes_expected: bytes) -> None:
22
40
  assert hexbytes == bytes_expected
23
41
  assert len(hexbytes) == len(bytes_expected)
24
42
  for byte_actual, byte_expected in zip(hexbytes, bytes_expected):
@@ -26,21 +44,21 @@ def assert_equal(hexbytes, bytes_expected):
26
44
  assert bytes(hexbytes) == bytes_expected
27
45
 
28
46
 
29
- @given(st.binary())
30
- def test_bytes_inputs(primitive):
47
+ @given(hypothesis.strategies.binary())
48
+ def test_bytes_inputs(primitive: bytes) -> None:
31
49
  wrapped = HexBytes(primitive)
32
50
  assert_equal(wrapped, primitive)
33
51
 
34
52
 
35
- @given(st.binary())
36
- def test_bytearray_inputs(primitive):
53
+ @given(hypothesis.strategies.binary())
54
+ def test_bytearray_inputs(primitive: bytes) -> None:
37
55
  byte_array_input = bytearray(primitive)
38
56
  wrapped = HexBytes(byte_array_input)
39
57
  assert_equal(wrapped, primitive)
40
58
 
41
59
 
42
- @given(st.binary())
43
- def test_memoryview_inputs(primitive):
60
+ @given(hypothesis.strategies.binary())
61
+ def test_memoryview_inputs(primitive: bytes) -> None:
44
62
  memoryview_input = memoryview(primitive)
45
63
  wrapped = HexBytes(memoryview_input)
46
64
  assert_equal(wrapped, primitive)
@@ -53,14 +71,14 @@ def test_memoryview_inputs(primitive):
53
71
  (False, "HexBytes('0x00')"),
54
72
  ),
55
73
  )
56
- def test_bool_inputs(boolval, expected_repr):
74
+ def test_bool_inputs(boolval: bool, expected_repr: str) -> None:
57
75
  wrapped = HexBytes(boolval)
58
76
  assert repr(wrapped) == expected_repr
59
- assert_equal(wrapped, standard_to_bytes(boolval))
77
+ assert_equal(wrapped, to_bytes(boolval))
60
78
 
61
79
 
62
- @given(st.integers(max_value=-1))
63
- def test_invalid_integer_inputs(integer):
80
+ @given(hypothesis.strategies.integers(max_value=-1))
81
+ def test_invalid_integer_inputs(integer: int) -> None:
64
82
  with pytest.raises(ValueError) as exc_info:
65
83
  HexBytes(integer)
66
84
 
@@ -69,15 +87,15 @@ def test_invalid_integer_inputs(integer):
69
87
  assert str(integer) in message
70
88
 
71
89
 
72
- @given(st.integers(min_value=0))
73
- def test_integer_inputs(integer):
90
+ @given(hypothesis.strategies.integers(min_value=0))
91
+ def test_integer_inputs(integer: int) -> None:
74
92
  wrapped = HexBytes(integer)
75
93
  assert hex(integer)[2:] in repr(wrapped)
76
- assert_equal(wrapped, standard_to_bytes(integer))
94
+ assert_equal(wrapped, to_bytes(integer))
77
95
 
78
96
 
79
97
  @given(hexstr_strategy)
80
- def test_hex_inputs(hex_input):
98
+ def test_hex_inputs(hex_input: str) -> None:
81
99
  wrapped = HexBytes(hex_input)
82
100
  if len(hex_input) % 2 == 0:
83
101
  even_hex_input = hex_input
@@ -87,23 +105,23 @@ def test_hex_inputs(hex_input):
87
105
  assert_equal(wrapped, expected)
88
106
 
89
107
 
90
- def test_pretty_output():
108
+ def test_pretty_output() -> None:
91
109
  hb = HexBytes(b"\x0F\x1a")
92
110
  assert repr(hb) == "HexBytes('0x0f1a')"
93
111
 
94
112
 
95
- def test_does_not_break_bytes_hex():
113
+ def test_does_not_break_bytes_hex() -> None:
96
114
  hb = HexBytes(b"\x0F\x1a")
97
115
  assert hb.hex() == "0f1a"
98
116
 
99
117
 
100
- def test_to_0x_hex():
118
+ def test_to_0x_hex() -> None:
101
119
  hb = HexBytes(b"\x0F\x1a")
102
120
  assert hb.to_0x_hex() == "0x0f1a"
103
121
 
104
122
 
105
- @given(st.binary(), st.integers())
106
- def test_hexbytes_index(primitive, index):
123
+ @given(hypothesis.strategies.binary(), hypothesis.strategies.integers())
124
+ def test_hexbytes_index(primitive: bytes, index: int) -> None:
107
125
  hexbytes = HexBytes(primitive)
108
126
  if index >= len(primitive) or index < -1 * len(primitive):
109
127
  with pytest.raises(IndexError):
@@ -112,23 +130,30 @@ def test_hexbytes_index(primitive, index):
112
130
  assert hexbytes[index] == primitive[index]
113
131
 
114
132
 
115
- @given(st.binary(), st.integers(), st.integers())
116
- def test_slice(primitive, start, stop):
133
+ @given(
134
+ hypothesis.strategies.binary(),
135
+ hypothesis.strategies.integers(),
136
+ hypothesis.strategies.integers(),
137
+ )
138
+ def test_slice(primitive: bytes, start: int, stop: int) -> None:
117
139
  hexbytes = HexBytes(primitive)
118
140
  expected = HexBytes(primitive[start:stop])
119
141
  assert hexbytes[start:stop] == expected
120
142
 
121
143
 
122
- @given(st.binary(), st.integers(), st.integers(), st.integers())
123
- def test_slice_stepped(primitive, start, stop, step):
144
+ @given(
145
+ hypothesis.strategies.binary(),
146
+ hypothesis.strategies.integers(),
147
+ hypothesis.strategies.integers(),
148
+ hypothesis.strategies.integers(),
149
+ )
150
+ def test_slice_stepped(primitive: bytes, start: int, stop: int, step: int) -> None:
124
151
  hexbytes = HexBytes(primitive)
125
- if step == 0:
126
- step = None
127
- expected = HexBytes(primitive[start:stop:step])
128
- assert hexbytes[start:stop:step] == expected
152
+ expected = HexBytes(primitive[start:stop:step or None])
153
+ assert hexbytes[start:stop:step or None] == expected
129
154
 
130
155
 
131
- def test_reduce_consistency():
156
+ def test_reduce_consistency() -> None:
132
157
  obj = HexBytes(b"0x1234")
133
158
 
134
159
  reduce_fn, reduce_args, *maybe_state = obj.__reduce__()
@@ -1,10 +1,10 @@
1
- def test_import_and_version():
1
+ def test_import_and_version() -> None:
2
2
  import faster_hexbytes
3
3
 
4
4
  assert isinstance(faster_hexbytes.__version__, str)
5
5
 
6
6
 
7
- def test_compiled_extension_loaded():
7
+ def test_compiled_extension_loaded() -> None:
8
8
  import importlib.machinery
9
9
  import sys
10
10
 
File without changes