Skip to content

Commit

Permalink
feat: widen allowed types for SnapshotID (#2442)
Browse files Browse the repository at this point in the history
Co-authored-by: antazoey <[email protected]>
  • Loading branch information
bitwise-constructs and antazoey authored Dec 23, 2024
1 parent 7ccc2f2 commit c5350e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/ape/types/vm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Literal, Union
from typing import Any, Literal, Union

from eth_typing import HexStr
from hexbytes import HexBytes
Expand All @@ -14,12 +14,12 @@
A type that represents contract code, which can be represented in string, bytes, or HexBytes.
"""

SnapshotID = Union[str, int, bytes]
SnapshotID = Any
"""
An ID representing a point in time on a blockchain, as used in the
:meth:`~ape.managers.chain.ChainManager.snapshot` and
:meth:`~ape.managers.chain.ChainManager.snapshot` methods. Can be a ``str``, ``int``, or ``bytes``.
Providers will expect and handle snapshot IDs differently. There shouldn't be a need to change
providers when using this feature, so there should not be confusion over this type in practical use
cases.
:meth:`~ape.managers.chain.ChainManager.snapshot` methods. Can be a ``str``, ``int``, ``bytes``,
``tuple[bytes, int]``, etc. Providers will expect and handle snapshot IDs differently.
There shouldn't be a need to change providers when using this feature, so there should not be
confusion over this type in practical use cases.
"""
2 changes: 1 addition & 1 deletion tests/functional/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_isolation_restore_not_implemented(mocker, networks, fixtures):
networks.active_provider = orig_provider


@pytest.mark.parametrize("snapshot_id", (0, 1, "123"))
@pytest.mark.parametrize("snapshot_id", (0, 1, "123", (b"123", 1)))
def test_isolation_snapshot_id_types(snapshot_id, fixtures):
class IsolationManagerWithCustomSnapshot(IsolationManager):
take_call_count = 0
Expand Down

0 comments on commit c5350e6

Please sign in to comment.