mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-133403: Check Tools/build/deepfreeze.py
with mypy (GH-133802) (#134040)
(cherry picked from commit 7eaa097390
)
This commit is contained in:
parent
f81f1bb2f9
commit
cec0e13fd4
4 changed files with 45 additions and 26 deletions
|
@ -146,12 +146,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:
|
||||
|
@ -307,15 +307,16 @@ def loads(data: bytes) -> Any:
|
|||
return r.r_object()
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
# Test
|
||||
import marshal, pprint
|
||||
sample = {'foo': {(42, "bar", 3.14)}}
|
||||
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__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue