Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: widen allowed types for SnapshotID #2442

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for whatever reasons, we have been sticking to 1 sentence per line in our markdown, that is why you see such long lines. We can change this but probably should be all changed at once.

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
Loading