gh-133403: Check Tools/build/deepfreeze.py with mypy (#133802)

This commit is contained in:
sobolevn 2025-05-15 12:13:03 +03:00 committed by GitHub
parent c3a1da5b93
commit 7eaa097390
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 25 deletions

View file

@ -145,12 +145,12 @@ class Reader:
def r_float_bin(self) -> float:
buf = self.r_string(8)
import struct # Lazy import to avoid breaking UNIX build
return struct.unpack("d", buf)[0]
return struct.unpack("d", buf)[0] # type: ignore[no-any-return]
def r_float_str(self) -> float:
n = self.r_byte()
buf = self.r_string(n)
return ast.literal_eval(buf.decode("ascii"))
return ast.literal_eval(buf.decode("ascii")) # type: ignore[no-any-return]
def r_ref_reserve(self, flag: int) -> int:
if flag:
@ -306,7 +306,7 @@ def loads(data: bytes) -> Any:
return r.r_object()
def main():
def main() -> None:
# Test
import marshal
import pprint
@ -314,8 +314,9 @@ def main():
data = marshal.dumps(sample)
retval = loads(data)
assert retval == sample, retval
sample = main.__code__
data = marshal.dumps(sample)
sample2 = main.__code__
data = marshal.dumps(sample2)
retval = loads(data)
assert isinstance(retval, Code), retval
pprint.pprint(retval.__dict__)