Tools for static type checking in Python

前端 未结 7 1900
灰色年华
灰色年华 2020-12-01 09:00

I\'m working with a large existing Python codebase and would like to start adding in type annotations so I can get some level of static checking. I\'m imagining something l

相关标签:
7条回答
  • 2020-12-01 09:45

    Check out this post: PySonar: a Static Analyzer for Python. PySonar is a tool that infers types using abstract interpretation (partially executing) of code. It finds all possible execution paths of your program and finds all possible types of all variables.

    There are basically three versions of PySonar:

    • Open-sourced Java (Jython indexer)
    • Closed-sourced Java (Hidden in Google)
    • Open-sourced Python (mini-pysonar)

    None of them (except of closed source one) is fully implemented. But the basic idea is that you can use it as a basis for your work.

    0 讨论(0)
提交回复
热议问题