Skip to content

Commit e66b640

Browse files
committed
almost, but not quite
1 parent bdbb737 commit e66b640

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

clvm/op_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ def operators_for_dict(
2121
return d
2222

2323

24-
def operators_for_module(keyword_to_atom: Dict[str, bytes], mod: types.ModuleType, op_name_lookup: Optional[Dict[str, str]] = None) -> Dict[bytes, OperatorProtocol]:
24+
def operators_for_module(
25+
keyword_to_atom: Dict[str, bytes],
26+
mod: types.ModuleType,
27+
op_name_lookup: Optional[Dict[str, str]] = None,
28+
) -> Dict[bytes, OperatorProtocol]:
2529
if op_name_lookup is None:
2630
op_name_lookup = {}
2731
return operators_for_dict(keyword_to_atom, mod.__dict__, op_name_lookup)

clvm/serialize.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
if typing.TYPE_CHECKING:
24-
from .SExp import SExp
24+
from .SExp import CastableType, SExp
2525

2626

2727
MAX_SINGLE_BYTE = 0x7F
@@ -30,12 +30,13 @@
3030

3131
T = typing.TypeVar("T")
3232

33+
ToSExp = typing.Callable[["CastableType"], CLVMStorage]
3334

3435
OpCallable = typing.Callable[
35-
["OpStackType", "ValStackType", typing.BinaryIO, typing.Type], None
36+
["OpStackType", "ValStackType", typing.BinaryIO, ToSExp], None
3637
]
3738

38-
ValStackType = typing.List["SExp"]
39+
ValStackType = typing.List[CLVMStorage]
3940
OpStackType = typing.List[OpCallable]
4041

4142

@@ -100,7 +101,7 @@ def sexp_to_stream(sexp: SExp, f: typing.BinaryIO) -> None:
100101

101102

102103
def _op_read_sexp(
103-
op_stack: OpStackType, val_stack: ValStackType, f: typing.BinaryIO, to_sexp: typing.Callable[[bytes], SExp],
104+
op_stack: OpStackType, val_stack: ValStackType, f: typing.BinaryIO, to_sexp: ToSExp,
104105
) -> None:
105106
blob = f.read(1)
106107
if len(blob) == 0:
@@ -118,14 +119,14 @@ def _op_cons(
118119
op_stack: OpStackType,
119120
val_stack: ValStackType,
120121
f: typing.BinaryIO,
121-
to_sexp: typing.Callable[[typing.Tuple[SExp, SExp]], SExp],
122+
to_sexp: ToSExp,
122123
) -> None:
123124
right = val_stack.pop()
124125
left = val_stack.pop()
125126
val_stack.append(to_sexp((left, right)))
126127

127128

128-
def sexp_from_stream(f: typing.BinaryIO, to_sexp: typing.Callable[[SExp], T]) -> T:
129+
def sexp_from_stream(f: typing.BinaryIO, to_sexp: ToSExp) -> CLVMStorage:
129130
op_stack: OpStackType = [_op_read_sexp]
130131
val_stack: ValStackType = []
131132

@@ -188,8 +189,8 @@ def sexp_buffer_from_stream(f: typing.BinaryIO) -> bytes:
188189

189190

190191
def _atom_from_stream(
191-
f: typing.BinaryIO, b: int, to_sexp: typing.Callable[[bytes], T]
192-
) -> T:
192+
f: typing.BinaryIO, b: int, to_sexp: ToSExp
193+
) -> CLVMStorage:
193194
if b == 0x80:
194195
return to_sexp(b"")
195196
if b <= MAX_SINGLE_BYTE:

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ files = clvm,tests,*.py
33
show_error_codes = True
44
warn_unused_ignores = True
55

6-
;disallow_any_generics = True
6+
disallow_any_generics = True
77
disallow_subclassing_any = True
88
disallow_untyped_calls = True
99
disallow_untyped_defs = True

0 commit comments

Comments
 (0)