{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/hityper-a-hybrid-static-type-inference","title":"Static Inference Meets Deep Learning: A Hybrid Type Inference Approach for Python","arxiv_id":"2105.03595","date":"2021-05-08","proceeding":null,"authors":["Yun Peng","Cuiyun Gao","Zongjie Li","Bowei Gao","David Lo","Qirun Zhang","Michael Lyu"],"abstract":"Type inference for dynamic programming languages such as Python is an important yet challenging task. Static type inference techniques can precisely infer variables with enough static constraints but are unable to handle variables with dynamic features. Deep learning (DL) based approaches are feature-agnostic, but they cannot guarantee the correctness of the predicted types. Their performance significantly depends on the quality of the training data (i.e., DL models perform poorly on some common types that rarely appear in the training dataset). It is interesting to note that the static and DL-based approaches offer complementary benefits. Unfortunately, to our knowledge, precise type inference based on both static inference and neural predictions has not been exploited and remains an open challenge. In particular, it is hard to integrate DL models into the framework of rule-based static approaches. This paper fills the gap and proposes a hybrid type inference approach named HiTyper based on both static inference and deep learning. Specifically, our key insight is to record type dependencies among variables in each function and encode the dependency information in type dependency graphs (TDGs). Based on TDGs, we can easily integrate type inference rules in the nodes to conduct static inference and type rejection rules to inspect the correctness of neural predictions. HiTyper iteratively conducts static inference and DL-based prediction until the TDG is fully inferred. Experiments on two benchmark datasets show that HiTyper outperforms state-of-the-art DL models by exactly matching 10% more human annotations. HiTyper also achieves an increase of more than 30% on inferring rare types. Considering only the static part of HiTyper, it infers 2x ~ 3x more types than existing static type inference tools.","url_abs":"https://arxiv.org/abs/2105.03595v2","url_pdf":"https://arxiv.org/pdf/2105.03595v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"hityper-a-hybrid-static-type-inference","repo_url":"https://github.com/johnnypeng18/hityper","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2105.03595","atlas_url":"https://app.syntology.ai/?focus=2105.03595","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2105.03595"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/johnnypeng18/hityper","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":4,"unverified":2},"by_repo_kind":{"listed":{"samples":6,"ran":4,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"f6c640cee9b4f934","entry":"Attribute2Str","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/tdg_generator.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/tdg_generator.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f6c640cee9b4f934"}},{"code_sha256_prefix":"91a8126612fe51df","entry":"checkAttribute","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/tdg.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/tdg.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"91a8126612fe51df"}},{"code_sha256_prefix":"600500c1449505e7","entry":"detectChange","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/utils.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"600500c1449505e7"}},{"code_sha256_prefix":"7b85a1aedf8ca646","entry":"formatUserTypes","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/utils.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7b85a1aedf8ca646"}},{"code_sha256_prefix":"8ec883ee84922ea8","entry":"Attribute2Str_Call","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/tdg_generator.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/tdg_generator.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8ec883ee84922ea8"}},{"code_sha256_prefix":"f27d65fdc942fd09","entry":"transformConstant","repo":"johnnypeng18/hityper","repo_kind":"listed","path":"hityper/tdg_generator.py","file_url":"https://github.com/johnnypeng18/hityper/blob/HEAD/hityper/tdg_generator.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f27d65fdc942fd09"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}