NL idZddlmZddlmZddlmZddlmZddl m Z m Z m Z ddl mZmZddlmZdd lmZdd lmZmZdd Zdd Zdd ZddZddZy)z=Functions to check that serialization round-tripped properly.) annotations)Iterable)Any)ClassIR)FuncDeclFuncIR FuncSignature)ModuleIRdeserialize_modules) DeserMaps)RType)is_same_signature is_same_typect|dr2|jDcic]}t||s|t||c}St|jScc}w)N__mypyc_attrs__)hasattrrgetattrdict__dict__)xks c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/test/test_serialization.pyget_dictrsLq#$*+*;*;MQwq!}71a= MMAJJNs AAcdt|}|jdd|jdd|S)zFGet a dict of function attributes safe to compare across serializationblocksNenv)rpop)rds rget_function_dictrs, AEE(DEE% Hcpt|t|usJd|t|t|ft|tttfr$|j |j k(s Jd|yt|t rt|jt|jk(s Jd|t|j|jD],\\}}\}}t|||dzt||||fz.yt|t rX|j|jk(s Jd||jD]}t||||||fzyt|trHt|ttfs2tt||D]\}\}}t||||fzyt|t rt#||s Jd|yt|t$rt'||s Jd|y||k(s Jd|y) aCompare two blobs of IR as best we can. FuncDecls, FuncIRs, and ClassIRs are compared by fullname to avoid infinite recursion. (More detailed comparisons should be done manually.) Types and signatures are compared using mypyc.sametype. Containers are compared recursively. Anything else is compared with ==. The `trail` argument is used in error messages. zType mismatch at zName mismatch at zKeys mismatch at )keyszRType mismatch at zSignature mismatch at zValue mismatch at N)type isinstancerrrfullnamerlenr"zipitemsassert_blobs_samerstrset enumerater rr r) rytrailxkxvykyvris rr)r)"s  7d1g N"3E7 ;T!Wd1gNN !h01zzQZZ'D+sBN)rrreturndict[str, Any])rrrIrJ)rrr-rr.ztuple[Any, ...]rINone)r:r r;r rIrK)rCzdict[str, ModuleIR]rIrK)__doc__ __future__rcollections.abcrtypingrmypyc.ir.class_irrmypyc.ir.func_irrrr mypyc.ir.module_irr r mypyc.ir.opsr mypyc.ir.rtypesr mypyc.sametyperrrrr)r@rHr rrWsCC #$%<<<"!:  '4TW. -r