Skip to content

Question: usage as a library #385

@bchurchill

Description

@bchurchill

I'm developing a static analysis for python code that depends on type information. I'd really like to use an existing type analysis instead of building my own! Is it possible to use pytype as a library?

The best case scenario for me would be to annotate every node of an AST with some kind of overapproximation of the type information (e.g. a list of possible types, a type with a hole in it, etc.). For example, I would like to write code like this:

my_ast = ast.parse(some_python_code)
typed_ast = pytype.analyze(my_ast)
...
class MyVisitor(ast.NodeVisitor):

  def generic_visit(self,node):
      print("This node has type " + str(node.type))

Is something like this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions