Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit cc0f679

Browse files
cburgdorfpipermerriam
authored andcommitted
Fix typing errors
1 parent 2b032ec commit cc0f679

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

evm/db/journal.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import collections
2-
from typing import Dict, Union # noqa: F401
2+
from typing import cast, Dict, Union # noqa: F401
33
import uuid
44

55
from cytoolz import (
@@ -119,7 +119,7 @@ def commit_changeset(self, changeset_id: uuid.UUID) -> Dict[bytes, bytes]:
119119
#
120120
# Database API
121121
#
122-
def __getitem__(self, key: bytes) -> bytes:
122+
def __getitem__(self, key: bytes) -> Union[bytes, DeletedEntry]:
123123
"""
124124
For key lookups we need to iterate through the changesets in reverse
125125
order, returning from the first one in which the key is present.
@@ -178,7 +178,9 @@ def __getitem__(self, key: bytes) -> bytes:
178178
elif val is None:
179179
return self.wrapped_db[key]
180180
else:
181-
return val
181+
# mypy doesn't allow custom type guards yet so we need to cast here
182+
# even though we know it can only be `bytes` at this point.
183+
return cast(bytes, val)
182184

183185
def __setitem__(self, key: bytes, value: bytes) -> None:
184186
"""

0 commit comments

Comments
 (0)