Replies: 1 comment
-
Pyright wasn't designed for what you're trying to do, so there's no API or plugin model available to do that. Of course, you could fork the project and with sufficient changes, you could accomplish what you're trying to do. The closest thing in pyright to what you have described above is the packageTypeVerifier.ts module, which is used to implement the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to develop a static analysis tool for Python code that would, given a Python package, output a directed graph representing the type system. The nodes of this graph are types and functions (including methods). An edge T -> F exists from a type T to a function F if F takes an argument of type T, and an edge F -> T exists if F outputs type T. There are obvious problems with this model like how I'll deal with unions and optionals, but that's a different conversation.
Could I somehow adapt Pyright for my purposes? The hard problem that I wasn't able to figure out on my own is how to output a listing of every type and every function in the codebase, with the type annotations of the functions correctly resolved to point back to that same type listing. That last part turned out to be the hard part when I tried doing this on my own in Python, just by checking
__annotations__
and what not.I'll take either analyzing Pyright's logs, or building some kind of Pyright plugin if there's a plugin system, or even just forking Pyright if that would be reasonably feasible.
Beta Was this translation helpful? Give feedback.
All reactions